0% found this document useful (0 votes)
19 views6 pages

XII IP Class Test Pandas

The document is a Class Test worksheet for XII - IP students at PM SHRI Kendriya Vidyalaya, Churu, focusing on the topic of Series in Python using the pandas library. It includes various programming questions related to creating series, accessing elements, filtering values, and understanding pandas functionalities. Additionally, it contains multiple-choice questions and programming tasks to assess students' knowledge and skills in handling data with pandas.

Uploaded by

nischayrathore4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

XII IP Class Test Pandas

The document is a Class Test worksheet for XII - IP students at PM SHRI Kendriya Vidyalaya, Churu, focusing on the topic of Series in Python using the pandas library. It includes various programming questions related to creating series, accessing elements, filtering values, and understanding pandas functionalities. Additionally, it contains multiple-choice questions and programming tasks to assess students' knowledge and skills in handling data with pandas.

Uploaded by

nischayrathore4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PM SHRI KENDRIYA VIDYALAYA, CHURU (RAJASTHAN)

CLASS TEST APRIL 2025 XII – IP


TOPIC: Series (Create Series, Access element, Filter value)
WORKSHEET NO. 1
QN. Questions
1 Write a program to create a series to print scalar value “5” four times.
2 Write a program to create a series object F1 using a dictionary that stores the number of
furniture in each lab of your school.
Note: Assume four furniture names are Table, Sofa, Chair and stool having 40, 2,45,26
items respectively and pandas library has been imported as pd.
3 What will be the output of the following code: import pandas as
pd
L= [9,10,12]
S=pd.Series(L) Dbl=pd.Series(data = S*2)
print(“New Series: “) print(Dbl)

4 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.

5 What will be the output of the following code:


>>>import pandas as pd
>>>A=pd.Series(data=[35,45,55,40])
>>>print(A==data) What will be the
output:
a. True b. False c. [35,45,55,40] d. Error
6 Find the output of following program. import numpy as np
d=np.array([10,20,30,40,50,60,70])
print(d [-4:])
7 What will be the output of the following code:
>>>import pandas as pd
>>>A=pd.Series(data=[35,45,55,40])
>>>print (A[A>45])
8 Write the output of the given command: import pandas as pd
s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F'])
print(s[s%2==0])
9 What will be the output of the following code:
>>>import pandas as pd
>>>A=pd.Series(data=[35,45,55,40])
>>>print ([A>45])
10 What will be the output of the following code:
>>>import pandas as pd
>>>A=pd.Series(data=[35,45,55,40])
>>>A[2:5]=25
>>>print (A)
11 Write a program to create a series object comp using a list that stores the number of quantity
of computer item in lab of your school. Note: Assume four computer item names as index are
KB, Mouse, computer and printer
havingvalues are 30, 25, 20, 2 items respectively and pandas library has been imported as pd.

W-2
12 Which attribute is used to get total number of elements in a Series?
a. size b. itemsize
c. shape d. ndim
13 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()
14 To display top five rows of a series object ‘S’, you may write:
a. S.head()
b. S.Tail(5)
c. S.Head(5)
d. S.tail()
15 method in Pandas can be used to change the index of rows and
columns of a Series or DataFrame:
(i) rename() (ii) reindex() (iii) reframe() (iv) none of the above
16 CSV stands for
17 Pandas Series is:
a. 2-Dimensional b. 3-Dimensional c. 1 Dimensional d. Multidimensional
18 Python pandas was developed by:
a. Guido van Rossum b. Travis Oliphant
c. Wes McKinney d. Brendan Eich
19 The command to install the pandas is:
a. install pip pandas b. install pandas
c. pip pandas d. pip install pandas
20 The name “Pandas” is derived from the term:
a. Panel Data b. Panel Series
c. Python Document d. Panel Data Frame
21 We can analyse the data in pandas with
a. Series b. Data Frame
c. Both of the above d. None of the above
22 Pandas is a:
a. Package b. Language
c. Library d. Software
23 Which of the following import statement is not correct?
a. import pandas as CLASS12 b. import pandas as 1pd
c. import pandas as pd1 d. import pandas as pd
24 Which of the following is not an attribute of pandas data frame?
a. length b. T
c. Size d. shape
25 import pandas as pd
s=pd.Series([1,2,3,4,5], index=['akram','brijesh','charu','deepika','era'])
print(s['charu'])
a. 1 b. 2 c. 3 d. 4
26 Assuming the given series, named stud, which command will be used to print 5 as
output?
Amit 90
Ramesh 100
Mahesh 50
john 67
Abdul 89
Name: Student, dtype: int64
a. stud.index b. stud.length
c. stud.values d. stud.size
27 A social science teacher wants to use a pandas series to teach about Indian historical
monuments and its states. The series should have the monument names as values and
state names as indexes which are stored in the given lists, as shown in the code. Choose
the statement which will create the series:
import pandas as pd
Monument=['Qutub Minar','Gateway of India','Red Fort','Taj Mahal']
State=['Delhi','Maharashtra','Delhi','Uttar Pradesh']
a. S=df.Series(Monument, index=State)
b. S=pd.Series(State, Monument)
c. S=pd.Series(Monument, index=State)
d. S=pd.series(Monument, index=State)
28 Difference between loc() and iloc().:
a. Both are Label indexed based functions.
b. Both are Integer position-based functions.
c. loc() is label-based function and iloc() integer position-based function.
d. loc() is integer position-based function and iloc() index position-based function.
29 Method or function to add a new row in a Series is:
a. .locate() b. .loc()
c. join d. add()
30 Rasha wants to set all the values to zero in Series, choose the right command to
do so:
a. S1=0 b. S1[]=0
c. S1[:]=0 d. S1[:]==0
31 Write the output of the given program: import pandas as pd
S1=pd.Series([5,6,7,8,10],index=['v','w',' x','y','z'])
Output required (5,)
a. print(S1.shape()) b. print(S1.shape)
c. print(S1.values) d. print(S1.size())
32 To check if the Series object contains NaN values, attribute is display.
a. hasnan b. nbytes
c. ndim d. hasnans
33 Consider the following series named animal:

Write the output of the command: print(animal[::-3])


34 Write the output of the given program:
import pandas as pd
S1=pd.Series([5,6,7,8,10], index=['v','w',' x','y','z'])
l=[2,6,1,4,6]
S2=pd.Series(l,index=['z','y','a','w','v'])
print(S1-S2)
35 Give the output:
import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6]) print(p)
p1=p.reindex([2,5])
print (p1)
36 Give the output: list1=[“Dance’,’Music’,’violin’,
‘guitar’,’drums’] list2=[100,200,300,400,500,600]
list3=list1[:2] list4=list2[2:5]
print(list3)
print(list4)
37 Consider the following series named color: Color
1 Red
2 Green
3 Orange
4 Yellow
5 Black
dtype: object
Write the command that generates the output as: 2
Green
4 Yellow
dtype: object
38 What will be the output of the given code? import
pandas as pd
s=pd.Series([3,6,9,12,14],index=['a','
b','c','d','e'])print(s[‘a’]+s[‘c’])
39

40 How many elements will be there in the series named “S1”?


>>> S1 = pd.Series(range(5,10))
>>> print(S1)
41 Consider the following series
CapCntry = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris', ’Tokyo’, ‘Beijing’],
index=['India', 'USA', 'UK', 'France', ‘Japan’, ‘China’])
Write the output of the following statements:
i) CapCntry[: : 2] ii) CapCntry[5:1:-1]
iii) CapCntry[: :-1] iv) CapCntry[3:]
42 Consider the following code. Write appropriate words to complete Line1:
import pandas as pd
Line2: import # Library name
Line3: A=np. (2,11,2) # function name to get numpy array
Line 4: S=pd.Series( , Index=[ ]) # Data name and indexes Line
5: Print(S)
QN. Answers
1 import pandas as pd S=pd.Series(5, index=[1,2,3,4,5])
2 import pandas as pd
F={‘Table’ :40, ‘Sofa’ :2, ‘Chair’ :45, ‘Stool’ :26} F1=pd.Series(St)
3

4 import pandas as pd
St={‘Beas’ :18, ‘Chenab’ :20, ‘Ravi’ :20, ‘Satluj’ :18} S1=pd.Series(St)
5 d. Error
6 [40 50 60 70]
7 2 55
dtype: int64
8 B 2
D 4
F 6
dtype: int64
9 0 False
1 False
2 True
3 False dtype: bool
10 0 35
1 45
2 25
3 25
dtype: int64

11 >>> i=['KB', 'Mouse', 'computer’,'printer']


>>> data=[30, 25, 20, 2]
>>> comp=pd.Series(data, index=i)
>>> print(comp)
12 Size
13 s.tail()
14 s.head()
15 reindex()
16 Comma separated value
17 c. 1 Dimensional
18 c. Wes McKinney
19 d. pip install pandas
20 a. Panel Data
21 c. Both of the above
22 c. Library
23 b. import pandas as 1pd
24 a. length
25 c. 3
26 d. stud.size

27 d. S=pd.Series(Monument,index=State)
28 c. loc() is label based function and iloc() integer position based function.
29 b.loc()
30 S1[:]=0
31 b. print(S1.shape)

32 (d) hasnans
33 W Wolf B Bear
dtype: object
34 x NaN
a NaN
v -1.0
w 2.0
y 2.0
z 8.0
dtype: float64
35 2 Raj
5 Ankur
6 Harsh dtype: object
2 Raj
5 Ankur dtype: object
36 0 Dance
1 Music
2 300
3 400
4 500
37 Color[2:5:2]
38 12
39

40 0 5
1 6
2 7
3 8
4 9
41 i) India NewDelhi UK
London
Japan Tokyo dtype: object
ii) CapCntry[5:1:-1] China Beijing
Japan Tokyo
France Paris
UK London dtype: object
iii) CapCntry[: :-1] China Beijing
Japan Tokyo
France Paris
UK London
USA WashingtonDC
India NewDelhi dtype: object
iv) CapCntry[3:] France
Paris
Japan Tokyo
China Beijing dtype: object
42 Line1: import pandas as pd
Line2: import_numpy as np # Library name
Line3: A=np.array(2,11,2) # function name to get numpy array
Line 4: S=pd.Series(_A , Index=[_0,1,2]) # Data name and indexes
Line 5: Print(S)

You might also like