Xii Ip HHW 2025
Xii Ip HHW 2025
CLASS-XII (IP)
SUMMER VACATION HOLIDAY HOME WORK 2025-26
1. The following table shows the python code and its expected output. Choose
the correct word for blank space in line 3 for printing the column:
A. index B. column C. col D. heads
Python code Output
1 import pandas as pd r1 10
2 x = [10, 20 30] r2 20
3 ser = pd.Series(x, =["r1", "r2", "r3"]) r3 30
4 print(ser)
import pandas as
pd list1=[-10,-20,-
30]
ser = pd.Series(list1*2)
print(ser)
4,Complete the given Python code to get the required output as:
Rajasthan import as pd
di = {'Corbett': 'Uttarakhand', 'Sariska': 'Rajasthan', 'Kanha': 'Madhya Pradesh’,
'Gir':'Gujarat'}
NP = . Series( )
print(NP[ ])
5. Write a program to create a series object using a dictionary that stores the number
of students
Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18
Jan 31
Feb 28
Mar 31
dtype:
int64
print(S1)
S1 = p1.series([31,28,31],
index=["Jan","Feb","Mar"]) print(S1)
S1 = pd.Series([31,28,31],
columns=["Jan","Feb","Mar"]) print(S1)
S1 = pd.Series([31,28,31], index=["Jan","Feb","Mar"])
print(S1)
01 Prerna Singh 24 24 20 22
12 Manish Arora 18 17 19 22
23 Tanish Goel 20 22 18 24
34 Falguni Jain 22 20 24 20
45 KanikaBhatnagar 15 20 18 22
56 Ramandeep Kaur 20 15 22 24
(a) The teacher needs to know the roll no, name and marks scored by the student
with roll number 4. Help her to write the code.
(b) Ms. Sharma, the class teacher wants to add a new column, the ‘Grade’ with
the values, ‘ A’, ‘B’, ‘A’, ‘A’, ‘B’, ‘A’ ,to the DataFrame. Help her to write code.
0 Aman 101 65 54 87 69 74
1 Suman 102 69 64 90 87 59
2 Priya 103 75 72 98 90 75
3 Tahir 104 88 80 78 45 87
4 Bharti 105 45 53 81 69 98
ii. Add a new row with values ( Rakesh ,106, 79 , 86, 91, 77, 93)
A B C
0 10 20 30
1 40 50 60
10.4. Write the correct output on execution of the following Pandas code
import pandas as pd
print(df)
S1 ATUL 51 35
S2 ANIL 62 61
S3 ANUJ 45 46
(A) Write commands to create the DataFrame (MRK) using a Dictionary of Lists
(B) If a DataFrame is created using a 2D dictionary, then the column labels are
formed from the inner dictionary’s keys or outer dictionary’s keys?
12. What do you mean by Series in Python? Give all the methods of creating series
in pandas.
14. Consider the following Series object “S1” and write the output of the
following statement:
import pandas as pd
S1 = pd.Series(L1)
print("1.
",S1.index)
print("2. ",S1.values)
print("3. ",S1.shape)
print("4. ",S1.ndim)
print("5. ",S1.size)
print("6. ",S1.nbytes)
print("7. ",S1[0])
print("8. ",S1[2]+S1[0])
print("9. ",S1[5]**2)
print("10. ",S1.empty)
print("11.\n",S1[[1, 5,
6]])
print("12.\n",S1[5 : 7],"\n")
print("13.\n",S1[: : -1])
print("14.\n",S1>60)
print("15.\n",S1[S1>60])
print("16.\n",len(S1))
print("17.\n",S1.count())
print("18.\n",S1.head())
print("19.\n",S1.tail())
print("20.\n",S1[4:5] + S1[4:5])
15. What is DataFrame? Explain all the methods of creating a data frame
With examples.