Professional Documents
Culture Documents
Class 12 Unit Test 1 August 2022
Class 12 Unit Test 1 August 2022
SECTION–I (4 5 = 20)
(Answer all FOUR questions. Each question carries Five Marks)
1. Consider the following series object “primesrs” and answer the questions that follow
0 2
1 3
2 5
3 7
4 11
5 13
6 17
7 19
i) Identify the correct statement to create the above Series?
a. primesrs = pd.Series([2, 3, 5, 7, 11, 13, 17, 19], [1, 2, 3, 4, 5, 6, 7])
b. primesrs = pd.Series([2, 3, 5, 7, 11, 13, 17, 19], range(0, 7))
c. primesrs = pd.Series([0, 1, 2, 3, 4, 5, 6, 7], [2, 3, 5, 7, 11, 13, 17, 19])
d. primesrs = pd.Series([2, 3, 5, 7, 11, 13, 17, 19])
ii) Which of the following will gives first five rows as output?
a. primesrs[5:] b. primesrs.Head( ) c. primesrs[0:5] d. primesrs[0:4]
iii) Write a Python statement to displays values of series which are less than 11
iv) Write a Python statement to change the series to store the elements in sorted order
v) print(primesrs.nbytes) results into _______________?
7. Write a Python statement to empty a DataFrame that is already having some data?
8. Which of the following displays the 3rd, 4th and 5th columns (These are column numbers, not labels) from
the 6th to 9th rows (These are row numbers, not labels) of a dataframe DF? The dataframe DF is created
with default row indexes and column labels
a) DF.loc[6:9,3:5] b) DF.loc[5:8,2:4] c) DF.iloc[6:9,3:5] d) DF.iloc[5:8,2:4]
SECTION–III (6 2 = 12)
(Answer all SIX questions. Each question carries Two Marks)
9. Consider the following Series object namely S:
0 0.430271
1 0.617328
2 0.265421
3 0.836113
Write the output for the following statements?
(a) S*100
(b) S>0
(c) S1=pd.Series(S)
print(S1)
(d) S3=pd.Series(S1+3)
print(S3)
10. Find the error in the following code fragment and rewrite the correct code:
(a) S2=pd.Series([101, 102, 102, 104])
print(S2.index)
S2.index=[0, 1, 2, 3, 4, 5]
S2[5]=220
print(S2)
(b) S = pd.Series(2, 3, 4, 5, index=range(4))
(c) S1 = pd.Series([1, 2, 3, 4], index=range(7))
(d) S2 = pd.Series([1, 2, 3, 4], columns=[0, 1, 2, 3])
11. Distinguish between iloc and loc with respect to a Series, by taking a simple example?
12. Distinguish between pop( ) and drop( )?
13. Distinguish between iterrows( ) and iteriems( ). With which Data Structure these functions are used?
14. List four differences between Series and DataFrame?
SECTION–IV (1 4 = 4)
(Answer the ONE question given. It carries Four Marks)
15. Write a Python Script Program to create a DataFrame with initialization or input of some data and display
transpose of DataFrame, data of DataFrame in descending order based on any column of your choice?