NIDA SHAFIQ
Problem 1: Employee Dataset
Dataset:
import pandas as pd
import numpy as np
data = {
"Employee": ["Ali", "Sara", "Ahmed", "Zara", "Usman", "Hina"],
"Department": ["HR", "IT", "Finance", "IT", "HR", "Finance"],
"Salary": [50000, 75000, 60000, 82000, 45000, 67000],
"Experience": [2, 5, 3, 7, 1, 4]
}
df = [Link](data)
print(df)
Questions:
Find the average salary per department using Pandas.
Add a new column Bonus which is 10% of Salary if Experience ≥ 3, else 5% of
Salary.
Using NumPy, find the highest salary and lowest experience in the company.
Find the employee with the maximum total income (Salary + Bonus).
Problem 2: Student Grades
Dataset:
import pandas as pd
import numpy as np
data = {
"Name": ["Ayesha", "Bilal", "Kiran", "Omar", "Farah"],
"Math": [85, 49, 67, 90, 72],
"English": [78, 56, 88, 45, 69],
"Science": [92, 60, 73, 81, 55]
}
df = [Link](data)
print(df)
Questions:
Compute each student’s average score across all subjects.
Add a new column Grade: 'A' if average ≥ 80, 'B' if 60 ≤ average < 80, 'C'
otherwise.
Using NumPy, find the subject with the highest overall average marks.
Find the top 2 students based on average score.
Problem 3: Sales Analysis
Dataset:
import pandas as pd
import numpy as np
data = {
"Product": ["Shoes", "Shirt", "Watch", "Bag", "Glasses"],
"Price": [2500, 1200, 5000, 3000, 1500],
"Units_Sold": [40, 70, 25, 50, 60],
"Discount(%)": [10, 5, 20, 15, 0]
}
df = [Link](data)
print(df)
Questions:
Calculate the total revenue for each product after applying the discount.
Add a column Revenue_Category: 'High' if revenue ≥ 100,000; 'Medium' if
50,000 ≤ revenue < 100,000; 'Low' otherwise.
Using NumPy, find the product with maximum units sold.
Find the average price of products (before discount).