Python Revision (Assignment
Python Revision (Assignment
ASSI/IP/XII/April/2025-26
No. 2
Topic: SERIES
1. Which of the following command will show the last 3 rows from a Pandas Series named NP?
a. NP.Tail( ) b. NP.tail(3)
c. NP.TAIL(3) d. All of the above
2. To display last five rows of a series object ‘S’, you may write:
a. S.head( ) b. S.Tail(5)
c. S.head(5) d. S.tail( )
3. Assertion (A):- To use the Pandas library in a Python program, one must import it.
Reasoning (R): - The only alias name that can be used with the Pandas library is pd.
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
5. While trying to create series from dictionary, keys of dictionary become index.
(a) True (b) False (c) Depends on Python Version (d) None of the above
9. To get the size of the datatype of the items in Series object, you can use ______ attribute.
(a) index (b) size (c) itemsize (d) ndim
10. To get the number of elements in a Series object, attribute may be used.
(a) index (b) size (c) itemsize (d) ndim
11. To get the number of bytes of the Series data, attribute is displayed.
(a) hasnans (b) nbytes (c) ndim (d) dtype
14. 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[ ])
NP = pd.Series( di)
print(NP[ 'Sariska'])
15. Write a program to create a series object using a dictionary that stores the number of students in
each house of class 12D of your school.
Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18
students respectively and Pandas library has been imported as pd.
17. Which of the following code will generate the following output?
Jan 31
Feb 28
Mar 31
dtype: int64