Q1. Load the Employee Salary dataset into Python using Pandas. Code: import pandas as pd import numpy as np from math import ceil data = pd.read_csv("employee_salary_dataset.csv") print(len(data)) Q2. Determine the required sample size using the 95% confidence level and 5% margin of error. Code: #Sample Size Determination N = len(data) Z = 1.96 p = 0.5 E = 0.05 #Initial sample size n0 = (Z**2 * p * (1 - p)) / (E**2) #Adjusted sample size for finite population sample_size = n0 / (1 + ((n0 - 1) / N)) #Round upward sample_size = ceil(sample_size) print("Initial Sample Size",n0) print("Required Sample Size:", sample_size) Q3. Perform the following sampling techniques: ● Simple Random Sampling ● Systematic Sampling ● Stratified Sampling (based on Department) ● Cluster Sampling (based on Job Level) ● Convenience Sampling ● Purposive Sampling (Salary > ₹80,000) Code: 1. Simple Random Sampling: Code: random_sample = data.sample( n=sample_size, random_state=42 ) print(random_sample) 2 . Systematic Sampling: Code: #Systematic Sampling interval = N // sample_size np.random.seed(42) start = np.random.randint(0, interval) systematic_sample = data.iloc[ start::interval ].head(sample_size) print(systematic_sample) 3 . Stratified Sampling (based on Department) Code: stratified_parts = [] for gender, group in data.groupby("Department"): group_sample_size = round( len(group) / len(data) * sample_size ) selected_group = group.sample( n=group_sample_size, random_state=42 ) stratified_parts.append(selected_group) stratified_sample = pd.concat( stratified_parts, ignore_index=True ) print(stratified_sample) 4 .Cluster Sampling (based on Job Level) Code: clusters = data["Education_Level"].dropna().unique() np.random.seed(42) selected_cluster = np.random.choice(clusters) cluster_sample = data[ data["Education_Level"] == selected_cluster ] print(cluster_sample) 5. Convenience Sampling Code: convenience_sample = data.head(sample_size) print(convenience_sample) 6 .Purposive Sampling Code: purposive_sample = data[ data["Monthly_Salary"] >= 10000 ] print(purposive_sample) Q4. Compare the sample sizes and average salary obtained from each sampling technique. Code: comparison = pd.DataFrame({ "Sampling Technique": [ "Complete Dataset", "Simple Random", "Systematic", "Stratified", "Cluster", "Convenience", "Purposive" ], "Number of Records": [ len(data), len(random_sample), len(systematic_sample), len(stratified_sample), len(cluster_sample), len(convenience_sample), len(purposive_sample) ], "Average Salary":[ data["Monthly_Salary"].mean(), random_sample["Monthly_Salary"].mean(), systematic_sample["Monthly_Salary"].mean(), stratified_sample["Monthly_Salary"].mean(), cluster_sample["Monthly_Salary"].mean(), convenience_sample["Monthly_Salary"].mean(), purposive_sample["Monthly_Salary"].mean() ] }) comparison["Average Salary"] = ( comparison["Average Salary"].round(2) ) print("\nSampling Comparison:") display(comparison) Q5. Calculate descriptive statistics (Mean, Median, Standard Deviation, Minimum, Maximum) for the Salary column. Code: statistics = pd.DataFrame({ "Sampling Technique": [ "Mean", "Median", "Standard Deviation", "Minimum", "Maximum" ], "Average Salary":[ data["Monthly_Salary"].mean(), data["Monthly_Salary"].median(), data["Monthly_Salary"].std(), data["Monthly_Salary"].min(), data["Monthly_Salary"].max() ] }) display(statistics) Q6. Save each sampled dataset into separate CSV files. Code: random_sample.to_csv("Simple Random Sample.csv", index=False) systematic_sample.to_csv("Systematic Sample.csv", index=False) stratified_sample.to_csv("Stratified Sample.csv", index=False) cluster_sample.to_csv("Cluster Sample.csv", index=False) convenience_sample.to_csv("Convenience Sample.csv", index=False) purposive_sample.to_csv("purposive Sample.csv", index=False) print("All CSV Files generated Successfully")