Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

JAWAHAR NAVODAYA VIDYALAYA

VALASAPALLE (V), MADANAPALLE (M), ANNAMAYYA (CHITTOOR) DT.


UNIT TEST–I, AUGUST 2022
Class : XII Time : 1 ½ Hr
Subject: Informatics Practices Max. Marks : 40

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 _______________?

2. Choose the most suitable answer from the available choices


i) Which of the following statement(s) is/are false?
S1 : Dataframe is size-mutable
S2 : Dataframe is values-mutable
S3 : Dataframe is immutable
S4 : Dataframe is capable of holding multiple types of data
a. S1 & S3 b. S2 & S3 c. S4 & S3 d. S3 Only
ii) Given a DataFrame studf as below:
Sub1 Sub2 Sub3
1 85 87 49
2 26 18 50
1 40 51 62
Which of the following replaces the value 18 with 33?
a) studf.loc['Sub2 ', 2] = 33 b) studf.iloc[2, 'Sub2 '] = 33
c) studf['Sub2 '][2] = 33 d) None of these
iii) The axis=1 identifies a dataframe's ______________?
iv) Given a DataFrame df as below:
A B D
0 15 17 19
2 16 18 20
3 20 21 22
Write a statement to change the index column to “A”?
v) Assuming the name of the DataFrame as dfEmp, what is the correct syntax to return the dataframe
data in reverse order of rows?
a) dfEmp[::–1] b) dfEmp.reverse( ) c) print(dfEmp, ascending=False) d) dfEmp[–1::]
-2-
3. Given a DataFrame “Sales” as below:
2014 2015 2016 2017
Madhu 100.5 12000 20000 50000
Kusum 150.8 18000 50000 60000
Kinsuk 200.9 2000 70000 70000
Ankit 30000 30000 100000 80000
Shruti 40000 45000 125000 90000
Write Python statements to:
i) Display the last two rows of the dataframe Sales?
ii) Add data to Sales for salesman Sumeet where the sales made are [196.2, 37800, 52000, 78438] in the
years [2014, 2015, 2016, 2017] respectively
iii) Delete the data for the year 2014 from the DataFrame Sales
iv) Update the sales made by Kinsuk on 2015 to 100000
v) Display the sales made by Madhu and Ankit in the year 2017 and 2018
4.
i) What type of error is returned by the following statement?
import pandas as pa
pa.Series([1,2,3,4], index=['a','b','c'])
a. Value Error b. Syntax Error c. Name Error d. Logical Error
ii) Consider the following series
ser = pd.Series([C, O, M, F, O, R, T, A, B, L, E],
index=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
Write the output for the following statement
print(ser[4:])
iii) Consider the following code
import pandas as pd
S1 = pd.Series([23, 24, 35, 56], index=[a, b, c, d])
S2 = pd.Series([27, 12, 14, 15], [b, y, c, ab])
df = pd.DataFrame(S1+S2)
Write the output for the statement
print (df)

iv) Consider the following Series objects


>>> srs1 >>> srs2 >>> srs3 >>> srs4
1 15 1 22 2 25 1 52
2 8 2 11 4 3 3 30
3 10 3 7 6 14 5 41
4 4 4 6 8 9 7 14
dtype: int64 dtype: int64 dtype: int64 dtype: int64
Which of the following does not generates any error
a. srs1 > srs3 b. srs2 < srs4 c. srs1 >= srs2 d. srs1 <= srs4
v) Mas. Preetam created a Series called S1 is like below
S1 = pd.Series([2,4,6,8,10], [1,2,3,4,5])
Now, another series S2 is created using existing series S1, like below
S2=pd.Series(S1)
Now, Mas. Preetam has written the following statement
S1[3]=100
Identify the correct choice from the following
a. S1[3] only will be changed and S2[3] will not be changed
b. S1[3] and S2[3] both will be changed
c. S1[3] will not be changed and S2[3] will be changed
d. Changing S1[3] is not possible and results in error
-3-
SECTION–II (4  1 = 4)
(Answer all FOUR questions. Each question carries One Mark)
5. Write the command to install pandas?
6. Consider the following statement for Series Object creation using a dictionary
weekdays=pd.Series({1: "Sun", 2: "Mon", 3: "Tue", 4: "Wed"}, index=[1.1, 2.0, 3.3, 4.0])
What shall be the output for the statement
print(weekdays)
a) 1.1 NaN b) 1 Sun c.) 1.1 Sun d) 1 NaN
2.0 Mon 2 Mon 2.0 Mon 2 Mon
3.3 NaN 3 Tue 3.3 Tue 3 NaN
4.0 Wed 4 Wed 4.0 Wed 4 Wed
dtype: object dtype: object dtype: object dtype: object

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?

You might also like