Ans Key Set A
Ans Key Set A
students = pd.DataFrame(data)
# i) Add marks of Subject1 and Subject2 and assign them to the column Total_Marks
students["Total_Marks"] = students["Subject1"] + students["Subject2"]
# ii) Display the average marks of each student across Subject1 and Subject2
students["Average_Marks"] = students["Total_Marks"] / 2
# iii) Display the details of the student with the highest Total_Marks
highest_marks_student = students[students["Total_Marks"] == students["Total_Marks"].max()]
ANS. B) [3]
import matplotlib.pyplot as plt
1
# Adding labels and title
plt.xlabel("Streams")
plt.ylabel("Number of Students")
plt.title("Students Enrolled per Stream")
SELECT Title, Author FROM LIBRARY WHERE Title LIKE '%Python%' OR Price > 400;
13 (The Alchemist)
18 (Think Like a Monk)
20 (Python Programming)
13 (Atomic Habits)
2
2. SELECT SUBSTRING(Title, 1, 5) FROM LIBRARY;
The A
Think
Pytho
Atomi
3. SELECT ROUND(AVG(Price), 2) FROM LIBRARY WHERE Category = 'Self-Help';
400.00
4. SELECT MAX(Price), Category FROM LIBRARY GROUP BY Category;
330 Fiction
450 Self-Help
650 Programming
—-----------------------------------------------------------------------------------------
SET -B
ANS. 1 A) [5]
import pandas as pd
employees = pd.DataFrame(data)
# Calculate the average salary
employees["Average_Salary"] = (employees["Salary1"] + employees["Salary2"]) / 2
3
finance_employees = employees[employees["Dept"] == "Finance"]
ANS.1 B) [3]
ANS.2 [5]
I) SELECT Name FROM EMPLOYEES WHERE Experience > 7;
—------------------------------------------------------------------------------------------------
4
—------------------------------------------------------------------------------------------------
4) UPDATE EMPLOYEES
SET Salary = Salary * 1.08
WHERE Department = 'Finance';
—------------------------------------------------------------------------------------------------
2) Full_Details
-------------------------
Aditi Sharma (HR)
Rahul Verma (IT)
Sneha Malhotra (Finance)
Karan Mehta (IT)
—------------------------------------------------------------------------------------------------
3) Total_Employees
-----------------
3
—------------------------------------------------------------------------------------------------
4) Lowest_Salary Department
---------------------------
60000 HR
75000 Finance
85000 IT
—------------------------------------------------------------------------------------------------
5
6