wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CBSE Python Series Questions

Total questions: 66

Worksheet time: 2hrs 43mins

Name
Class
Date
1.

A Series is a one dimensional array containing a sequence of values of any data type (int, float, list, string, etc), having by default have ________ data labels.

a)

alphanumeric

b)

string

c)

decimal

d)

numeric

2.

Find the output of the following code: import pandas as pd lst1=[20,35,40] ser1=pd.Series([20,35,40]) print(lst1+lst1) print(ser1+ser1)

4 lines
3.

Complete the given Python code to get the required output as "California": import_____________as pd data={'Yosemite':'California','Yellowstone':'Wyoming','Glacier':'Montana','RockyMountain':'Colorado'} national_parks=pd.Series(_____________) print(national_parks _________)

4 lines
4.

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

5.

In Python Pandas, while performing mathematical operations on series, index matching is implemented and all missing values are filled in with _____by default.

a)

Null

b)

Blank

c)

NaN

d)

Zero

6.

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.

a)

Both A and R are true and R is the correct explanation for A

b)

Both A and R are true and R is not the correct explanation for A

c)

A is True but R is False

d)

A is false but R is True

7.

Predict the output of the given Python code: import pandas as pd list1=[-10,-20,-30] ser = pd.Series(list1*2) print(ser)

4 lines
8.

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[ ___________ ])

4 lines
9.

Which of the following is a one-dimensional array containing a sequence of values in Python ?

a)

Relation

b)

DataFrame

c)

Series

d)

Square

10.

In Python Pandas, head(n) method returns the first n members of the series.What is the default value of n?

a)

2

b)

3

c)

4

d)

5

11.

What will be the output of the following code ? import pandas as pd S1=pd.Series(data=[1,7]) S2=pd.Series(S1+S1) print(S2)

4 lines
12.

Write a program in Python Pandas to create a series "car" from the following Dictionary : dic={"Model":["Samurai","Accord","CR-V","Nexon"],"Brand":["Suzuki","Honda","Honda","Tata"],"Make":[1993,1997,1997,2021]}

4 lines
13.

What will be the output of the following code? import pandas as pd myser=pd.Series([0, 0, 0]) print(myser)

a)

0 0

b)

0 1 0 0

c)

0 0 1 0 2 0

d)

0 0 1 1 2 2

14.

Assertion (A) : The output of addition of two series will by NAN, if one of the elements or both the elements have no value(s). Reason (R): While performing mathematical operations on a series, by default all missing values are filled in with 0.

a)

(A) is true but (R) is false

b)

(A) is false but (R) is true

15.

Write a Python program to create a series object, country using a list that stores the capital of each country. Note: Assume four countries to be used as index of the series object are India, UK, Denmark, and Thailand having their capitals as New Delhi, London, Copenhagen, and Bangkok respectively.

4 lines
16.

What will be the output of the following code: import pandas as pd s1=pd.Series(data=2*(3,10)) print(s1)

4 lines
17.

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()

18.

Which of the following statement will import pandas library?

a)

Import pandas as pd

b)

import Pandas as py

c)

import pandas as pd

d)

import panda as pd

19.

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.

4 lines
20.

What will be the output of the following code: >>>import pandas as pd >>>A=pd.Series(data=[35,45,55,40]) >>>print(A>45)

4 lines
21.

Which of the following statement is wrong?

a)

Can't change the index of the Series

b)

We can easily convert the list, tuple and dictionary into a series

c)

A Series represents a single column in memory

d)

We can create empty Series

22.

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

23.

Which is incorrect statement for the python package Numpy?

a)

It is a general purpose array processing package.

b)

Numpy arrays are faster and more compact

c)

It is multi-dimensional arrays

d)

It is proprietary software

24.

The data of any CSV file can be shown in which of the following software?

4 lines
25.

The data of any CSV file can be shown in which of the following software?

a)

MS Word

b)

Notepad

c)

Spreadsheet

d)

All of the above

26.

Which python library is not used for data science?

a)

Panda

b)

Numpy

c)

Matplotlib

d)

Tkinter

27.

What is the correct statement for the above output in the following statement 1?

a)

d=L*3

b)

data=L**3

c)

L*3

d)

[10,20]**3

28.

Which attribute is used with Series to count the total number of NaN values (non NaN values)?

a)

size

b)

len

c)

count

d)

count total

29.

Which statement will display all odd values?

a)

print(data%2= =0)

b)

print(data(data%2!=0)

c)

print(data mod 2!=0)

d)

print(data[data%3=0])

30.

What will be the output of the following code?

a)

0 False 1 True 2 False 3 True 4 False 5 False dtype:bool

b)

1 54 3 89 dtype:int64.

c)

0 31 1 54 2 34 3 89 4 12 5 23 dtype:int64

d)

1 True 3 True dtype:bool

31.

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]) print(ser[4: ])

a)

4 F 5 O 6 R 7 T 8 A 9 B 10 L 11 E dtype:object

b)

4 F 5 O 6 R 7 T 8 A dtype:object

c)

4 F 5 O 6 R 7 T 8 A 9 B dtype:object

d)

5 O 6 R 7 T 8 A 9 B 10 L 11 E dtype:object

32.

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],index=['b','y','c','ab']) df=pd.DataFrame(S1+S2) print(df) Output for the above code will be:

a)

0 a NaN ab NaN b 51.0 c 49.0 d NaN y NaN

b)

0 a 50 b 36 c 49 d 71

c)

0 b 50 y 36 c 49 ab 71

d)

0 a NaN ab NaN b NaN c NaN d NaN y NaN

33.

The name 'Pandas' is derived from the term:

a)

Panel Data

b)

Panel Series

c)

Python Document

d)

Panel Data Frame

34.

The command to install the pandas is:

a)

install pip pandas

b)

install pandas

c)

pip pandas

d)

pip install pandas

35.

Python pandas was developed by:

a)

Guido van Rossum

b)

Travis Oliphant

c)

Wes McKinney

d)

Brendan Eich

36.

Pandas Series is:

a)

2 Dimensional

b)

3 Dimensional

c)

1 Dimensional

d)

Multidimensional

37.

Pandas is a:

a)

Package

b)

Language

c)

Library

d)

Software

38.

We can analyse the data in pandas with

a)

Series

b)

Data Frame

c)

Both of the above

d)

None of the above

39.

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

40.

What will be the output of the given code? 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

41.

Assuming the given series, named stud, which command will be used to print 5 as output?

a)

stud.index

b)

stud.length

c)

stud.values

d)

stud.size

42.

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=['QutubMinar','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)

43.

Consider the following series named animal: L Lion B Bear E Elephant T Tiger W Wolf dtype:object Write the output of the command: print(animal[::-3])

a)

L Lion T Tiger dtype:object

b)

B Bear E Elephant dtype:object

c)

W Wolf B Bear dtype:object

d)

W Wolf T Tiger dtype:object

44.

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)

a)

a 0 v -1.0 w 2.0 x NaN y 2.0 z 8.0 dtype: float64

b)

a NaN v -1.0 w 2.0 x NaN y 2.0 z 8.0 dtype: float64

c)

v -1.0 w 2.0 y 2.0 z 8.0 dtype: float64

d)

a NaN v -1.0 w 2.0 x 3.0 y 2.0 z 8.0 dtype: float64

45.

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])

a)

B 0 D 0 F 0 dtype: int64

b)

A 1 B 2 C 5 dtype: int64

c)

B 2 D 4 F 6 dtype: int64

d)

B 1 D 2 F 3 dtype: int64

46.

Read the statements given below. Identify the right option from the following for Attribute and method/function. Statement A: Attribute always ends without parenthesis. Statement B: Function/Method cannot work without arguments.

a)

Both statements are correct.

b)

Both statements are incorrect.

c)

Statement A is correct, but Statement B is incorrect

d)

Statement A is incorrect, but Statement B is correct

47.

Series in Pandas to set the index label for the given object?

a)

label

b)

index

c)

loc

d)

All of the above

48.

Write a program in Python to create the series of all the alphabets of 'Happy' with default index. Print the first three alphabets.

4 lines
49.

Consider the following two series 'A' and 'B': A=pd.Series([2,4,6], index=[0,1,2]) B=pd.Series([1,3,5], index=[1,2,3]) (i) Write the statement to add both the series 'A' and 'B' (ii) Write the statement to multiply two series 'A' and 'B'

4 lines
50.

Create a series S1 with the values (2,3,1). (a) print(S1**3) (b) print(S1*3)

4 lines
51.

Given a Pandas series called Sequences, the command which will display the first 4 rows is _______________.

a)

print(Sequences.head(4))

b)

print(Sequences.Head(4))

c)

print(Sequences.heads(4))

d)

print(Sequences.Heads(4))

52.

Given the following Series S1 and S2: Write the command to find the sum of series S1 and S2.

4 lines
53.

Consider a given Series, M1: Write a program in Python Pandas to create the series.

4 lines
54.

Consider the following Series object, S_amt (i) Write the command which will display the name of the furniture having rent>250. (ii) Write the command to name the series as Furniture.

4 lines
55.

Consider two objects x and y. x is a list whereas y is a Series. Both have values 20, 40, 90, 110. What will be the output of the following two statements considering that the above objects have been created already. a. print (x*2) b. print(y*2) Justify your answer.

4 lines
56.

Find the output of following program: import numpy as np Profits=np.array([1520, 1245, 1345, 1525, 2110, 1020, 1725]) print(Profits[2:5])

4 lines
57.

Fill in the blank with appropriate numpy method to change the contents of the given 1 dimensional array Val1D into a 2 dimensional array Val2D with 3 rows and 2 columns per row: import numpy as np Val1D=np.array([15,25,35,45,55,65]) Val2D = ____________________________

4 lines
58.

Write the output of the following Python code: import numpy as np Score1=np.array([90,92,94,96,95]) Score2=np.array([95,90,98,96,92]) S1=(np.where(Score1>Score2)) S2=(np.where(Score2>Score1)) print(Score1[S1], Score2[S2])

4 lines
59.

Write single line Pandas statements for each of the following. (Assuming necessary modules have been imported): (i) Declare a Pandas series named Packets having dataset as: [125, 92, 104, 92, 85, 116, 87, 90] (ii) Display the median of the elements present in the dataset of Packets using the Pandas method for it.

4 lines
60.

Write Numpy single line statement for each of the following from (i) to (iii) (i) To create a 3 x 2 array named ARR2D with the following values. (Assuming necessary modules have been imported as np ): (ii) Assign the contents of the above array ARR2D to a new 1D array named ARR1D. (iii) Display content of array ARR1D as follows: [10 20 30 40 50 60]

4 lines
61.

Write Numpy single line statement for each of the following from (i) to (iii) (i) To create a 4 x 3 array named ARR with the following values. (Assuming necessary modules have been imported as np ): (ii) Topple the contents of the array ARR upside down so that its contents become: (iii) Display the changed content of the array ARR in the following format : [ [100 110 120 ] [ 70 80 90 ] [ 40 50 60 ] [ 10 20 30 ] ]

4 lines
62.

Find the output of following program: import numpy as np d=np.array([10,20,30,40,50,60,70]) print(d[-4])

4 lines
63.

Fill in the blank with appropriate numpy method to calculate or the covariance of an array import numpy as np data=np.array([1,2,3,4,5,6]) print(np. (a)   (data,ddof=0))

64.

Write the output of the following code : import numpy as np array1=np.array([10,12,14,16,18,20,22]) print(array1[1:5:2])

4 lines
65.

What is series? Explain with the help of an example.

4 lines
66.

Write a code in Python to search for a given value in a list of elements(Without using in-built function) Example: If the List contains: [20,30,40,50,60,80,120] and the element to be searched is:60 Then the output should be: Found at position 4 OR Write a code in python to find the minimum value in a list. Example: If the List contains: [100,150,90,65,180,200] Then the output should be: Minimum Value is 65

4 lines