Case Based MCQ Questions for Class 12 Informatics Practices – Python Pandas

Python Pandas Class 12 Case Based MCQ Questions

Case Study 1
Pandas Data Structure: A data structure is a particular way of storing and organising data in a computer to suit a specific purpose so that it can be accessed and worked with in appropriate ways. Pandas offer many data structures to handle a variety of data. At very basic level, Pandas data structure can be thought of somewhat as enhanced version
of NumPy structured arrays in which the rows and columns can be identified and accessed with labels rather than simple integer indices.

(a) Out of many data structures of Pandas, two basic data structures and are universally popular for their dependability.

(i) Series, Dataframe
(ii) Matplotlib, NumPy
(iii) ID array and 2D array
(iv) None of these
Answer:
(i) Series, Dataframe
Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(b) Dataframe is a data structure of Python Pandas.

(i) 2 – Dimensional
(ii) 1 – Dimensional
(iii) Both (i) and (ii)
(iv) None of these
Answer:
(i) 2 – Dimensional

(c) A Series is a Pandas data structure that represents a one-dimensional array like object containing an array of data and an associated array of data Labels, called its

(i) Row
(ii) Column
(iii) Label
(iv) Index
Answer:
(iv) Index

(d) When numeric indexes can depict positions of data in the objects (e.g., when indexes go as 0,1, 2,), they are called

(i) Labelled indexes
(ii) Positional indexes
(iii) Both (i) and (ii)
(iv) None of these
Answer:
(i) Labelled indexes

(e) A series type objects can be created in many ways using Pandas library’s

(i) Series ( )
(ii) SeriesObject( )
(iii) Series.Object( )
(iv) None of these
Answer:
(i) Series( )

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

Case Study 2

Consider the following DataFrame df and answer any four questions from (a) – (e):

Name UT1 UT2 UT3 UT4
1. Prerna Singh 24 24 20 22
2. Manish  Arora 18 17 19 22
3. Tanish Goel 20 22 18 24
4. Falguni Jain 22 20 24 20
5. Kanika Bhatnagar 15 20 18 22
6. Ramandeep Kaur 20 15 22 24

(a) Write down the command that will give the following output:

rollno   6
name   Tanish Goel
UT1     24
UT2     24
UT3     24
UT4     24
dtype: object

(i) print(df.max)
(ii) print(df.max())
(iii) print(df.max(axis=1))
(iv) print(df.max, axis=1)
Answer:
(ii) print(df.max())

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(b) The teacher needs to know the marks scored by the student with roll number 4. Help her identify the correct set of statement(s) from the given options:

(i) df1= df[df[‘rollno’] = 4) print(dfl)
(ii) df1= df(rollno = 4] print(dfl)
(iii) df1= df(df.rollno = 4] print(dfl)
(iv) dfl= df(df.rollno = 4) print(dfl)
Answer:
(i) dfl = df[df(‘rollno’)= 4] print (dfl)

(c) Which of the following statement(s) will give the exact number of values in each column of the dataframe?

I. print(df.countO)
II. print(df.count(0))
III. print(df.count)
IV. print((df.count(axis =‘index’))
Choose the correct option:
(i) I and II (ii) only II
(iii) I, II and III (iv) I, II and IV
Answer:
(i) I and II

(d) Which of the following command will display the column labels of the dataframe?

(i) print(df.columns())
(ii) print(df.column())
(iii) print(df.column)
(iv) print(df.columns)
Answer:
(iv) print(df.columns)

(e) Mrs. Sharma, the class teacher wants to add a new column, the scores of Grade with the values, X B’, X X B’, X to the dataframe. Help her choose the command to do so:

(i) df.column= (‘A’, ‘B’, A’, A’, ‘B’, A)
(ii) df[‘Grade’) =(A’, ‘B’, ‘A’, A’, ‘B’, A’]
(iii) df.loc(‘Grade’)= (A’, B’, A’, A’, ‘B’, A)
(iv) Both (ii) and (iii) are correct
Answer:
(ii) df(‘Grade’) = (A, ‘B’, A, A, ‘B’, A]

Case Study 3

Mr. Ankit is working in an organisation as data analyst. He uses Python Pandas and Matplotlib for the same. He got a dataset of the passengers for the year 2010 to 2012 for January, March and December. His manager wants certain information from him, but he is facing some problems..Help him by answering few questions given below:

Year Month Passengers
0 2010 Jan 25
1 2010 Mar 50
2 2012 Jan 35
3 2010 Dec 55
4 2012 Dec 65

Code to create the above dataframe: import pandas as ……… Statement data = {“Year”: [2010,2010,2012,2010,2012], ”Month”:
[“Jan”, “Mar”, “Jan”, “Dec”, “Dec”], “Passengers”:[25,50,35,55,65] } df=pd (data) #Statement 2 print(df)

(a) Choose the right code from the following for statement 1.

(i) pd
(ii) df
(iii) data
(iv) p
Answer:
(i) pd

(b) Choose the right code from the following for the statement 2.

(i) DataArray
(ii) DataFrame
(iii) Series
(iv) Dictionary
Answer:
(ii) DataFrame

(c) Choose the correct statement/method for the required output: (5,3)

(i) df.index
(ii) df,shape()
(iii) df.shape
(iv) df.size
Answer:
(iii) df.shape

(d) He wants to print the details of “January” month along with the number of passengers. Identify the correct statement:

Month Passengers
0 Jan 25
2 Jan 35
(i) df.loc([‘Month’,‘Passenger5’]][df(‘Month’)=-Jan’)
(ii) df((‘Month’,‘Passengers’]](df(‘Month’]==’Jan’]
(iii) df.iloc((‘Month’,,Passengers’])(df(‘Month’)==’Jan’)
(iv) df([‘Month’,’Passengers’]][df(‘Month’]==Jan’)
Answer:
(ii) df[(‘Month’,‘Passengers’])(df(‘Month’]==’Jan’]

(e) Mr. Ankit wants to change the index of the dataframe and the output for the same is given below. Identify the correct statement to change the index.

Year Month Passengers
Air India 2010 Jan 25
Indigo 2010 Mar 50
Spicejet 2012 Jan 35
Jet 2010 Dec 55
Emirates 2012 Dec 65

(i) df.index(]=[“Air India”,“Indigo”,“Spicejet”,”Jet”,“Emirates’]
(ii) df.index(“Air India”,“Indigo”,“Spiceiet”,”Jet”,”Emirates”]
(iii) df.index=(“Air India”,“Indigo”,“Spiceiet”,“Jet”,“Emirates”]
(iv) df.index()=[“Air India”,”Indigo”,“Spicejet”,“Jet”,“Emirates”]
Answer:
(iii) df.index=(“Air India”,“Indigo”,“SpicejetVJet”, “Emirates”]

Case Study 4

Answer the following based on the series given below. import pandas as pd listl=[l,2,3,4,5,6,7,8] list2=[‘swimming’,’tt’,’skating’,’kho kho’, ‘bb’, ‘chess’, ‘football’,”cricket”] school=pd.Series(listl,index=list2) school.name=(“little”) print (school*2) #statement 1 print (school.tail(3)) # statement 2 print (school[“tt”]) # statement 3 print (school[2:4]) # statement 4

(a) Choose the correct name of the series object given above.

(i) list 1
(ii) list 2
(iii) school
(iv) little
Answer:
(iv) little

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(b) Choose the correct output for the statement, print (school.tail(3)) # statement 2

(i) swimming 1
(ii) chess 6 tt 2 football 7 skating 3 cricket 8
(iii) 4
(iv) kho kho 4 bb 5 chess 6 football 7 cricket 8
Answer:
(ii) chess 6 football 7 cricket 8

(c) Choose the correct output for the statement, print (school[“tt”]). # statement 3

(i) 2
(ii) 3
(iii) tt 2
(iv) true
Answer:
(i) 2

(d) Identify the correct output for: print (school[2:4]) ft statement 4.
(ii) tt 2 skating 3 kho kho 4
(iv) skating 3 kho kho 4 bb 5 chess 6 football 7 cricket 8
Answer:
(i) skating 3 kho kho 4

(e) The correct output of the statetment: print (school*2) # statement 1 will be:

(i) swimming 3
(ii) swimming False
tt 4 tt False
skating 5 skating True
kho kho 6 kho kho True
bb 7 bb True
chess 8 chess True
football 9 football True
cricket 10 cricket True
(iii) swimming 2 tt 4
skating 6 kho kho 8 7 bb10 –
chess 12 football 14 cricket 16

Answer:
(iii) swimming 2 tt 4
skating 6 kho kho 8 bb 10 chess 12 football 14 cricket 16

Case Study 5

Sanyukta is the event incharge in a school. One of her students gave her a suggestion to use Python Pandas and Matplotlib for analysing and visualising the data, respectively. She has created a Data frame “SportsDay” to keep track of the number of First, Second and Third prizes won by different houses in various events.

House First Second Third
0.      Chenab 5 7 6
1.      Canges 10 5 4
2.      Jamuna 8 13 15
3.      Jhelum 12 9 12
4.      Ravi 5 11 10
5.      Satluj 10 5 3

Write Python commands to do the following:

(a) Display the house names where the number of Second Prizes are in the range of 12 to 20.

(i) df[‘Name’]((df(‘Second’)>=12) and (df[‘Second,)<=20)]
(ii) df(Name]((df[‘Second’]>=12) & (df(‘Second’]<=20)]
(iii) df(‘Name’)[(df(‘Second’)>=12) & (df[‘Second’]<=20)]
(iv) df[(df[‘Second’]>=12) & (df(‘Second’]<=20)]
Answer:
(iii) df(‘Name’]((df(‘Second’)>=12) & (df(‘Second’]<=20))

(b) Display all the records in the reverse order.

(i) print(df[::1])
(ii) print(df.iloc(::-1])
(iii) print(df(-1:]+df[:-1])
(iv) print(df.rever5e())
Answer:
(ii) print(df.iloc(::-1])

(c) Display the bottom 3 records.

(i) df.last(3)
(ii) df.bottom(3)
(iii) df.next(3)
(iv) df.tail(3)
Answer:
(iv) df.tail(3)

(d) Choose the correct output for the given statements. x=df.columns[:l] print(x)

(i) 0
(ii) Name
(iii) First
(iv) Error
Answer:
(ii) Name

(e) Which command will give the output 24?

(i) print(df.size)
(ii) print(df.shape)
(iii) print(df.index)
(iv) print(df.axes) ‘
Answer:
(i) print(df.size)

Case Study 6

Pushp, a student of class-XII, has been assigned a code to create a panda series SI, as shown below,
a 100
b 200
c 300
d 400
e 500
dtype: int64
With reference to the above answer given questions:

(a) Choose the command that will give the following output

b 200
c 300
dtype: int64
(i) print(Sl(:3])
(ii) print(S1(0:3])
(iii) print(51(1:3))
(iv) print(S1[2:4])
Answer:
(iii) print(S1(1:3))

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(b) Help him to identify the correct statement that can be used to extract the value with the index ‘c’.

(i) print(S1(c))
(ii) print(S1(c))
(iii) print(’51’ (‘c’])
(iv) print(S1 [‘c’])
Answer:
(iv) print(S1 (‘c’])

(c) Which of the following command will give the following output?

b 200
d 400
dtype: int64
(i) print(S1.iloc(1:4])
(ii) print(51.iloc(2:4])
(iii) print(S1.iloc(1:4))
(iv) print(Sl.iloc(l:4:2])
Answer:
(iv) print(S1.iloc(1:4:2))

(d) Which of the following command will display the series by adding 10 in each value?

(i) print(51 [+10])
(ii) print(51+10)
(iii) print(S1)+10
(iv) print(S1)+print(10)
Answer:
(ii) print(51+10)

(e) Pushp wants to delete the value against index’d’. Help him to choose the suitable option to do so:

(i) S1=S1.drop(‘d’)
(ii) S1=S1.drop(‘d’)
(iii) S1=drop(‘d’)
(iv) S1=S1.drop(’d’]
Answer:
(ii) S1=S1.drop(‘d’)

Case Study 7

Zeenat has created the following data frame dataframel to keep track of data Rollno, Name, Marksl and Marks2 for various students of her cLass where row indexes are taken as *he default values:

Name Marks 1 Marks 2
1 Swapnil Sharma 3b 50
2 Raj Batra 75 45
3 Bhoomi Singh 85 95
4 Jay Gupta 90 95

(a) Which among the following option will give 90, 95 as output?

(i) print(max(dataframe1(,MarksT,’Marks2′))
(ii) print((dataframe1.Marks1.max(),(dataframe1.Marks2. max())))
(iii) print(max(dataframe1[‘MarksT])
(iv) print(max(dataframe1[‘Marks2’))
Answer:
(ii) print((dataframe1.Marksl.max(),(dataframel.Marks2. max())))

(b) She needs to know the marks scored by Rollno 2. Help her to identify the correct set of statement/s from the given options.

(i) print(dataframe1(dataframe1(‘Rollno’]= =2])
(ii) print(dataframe1[‘Rollno’]= =2)
(iii) print(dataframe1(dataframe1. Rollno = =2))
(iv) print(dataframe1(dataframe1(‘Rollno’]))
Answer:
(iii) print(dataframe1(dataframe1. Rollno = =2])

(c) Which of the following statement/s will delete the 3rd column?

a. del dataframel[‘Marksl’]
b. dataframel.pop(‘Marksl’)
c. drop dataframel[‘Marksl’]
d. pop dataframel[‘Marksl’]
Choose the correct option.
(i) Both a. and b.
(ii) only b.
(iii) a. b. and c.
(iv) a., b. and d.
Answer:
(i) Both a. and b.

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(d) Which of the following command will display the total number of elements in the dataframe?

(i) print(dataframel.shape)
(ii) print(dataframel.num)
(iii) print(dataframelsize)
(iv) print(dataframe1.elements)
Answer:
(iii) print(dataframel.size)

(e) Now she wants to add a new column Marks3 with relevant data. Help her choose the command to perform this task.

(i) dataframel.column=[ 45,52,90,95]
(ii) dataframel [‘Marks3′]= [ 45,52,90,95]
(iii) dataframel.locfMarksB’]^ (45,52,90,95]
(iv) Both (ii) and (iii) are correct
Answer: (ii) dataframel (‘Marks3’]= (45,52,90,95]

Case Study 8

Naman has created the following dataframe “Climate” to record the data about climatic conditions of four years.

Year MaxTemp MinTemp Rainfall
2017 32 20 123
2018 33 22 140
2019 35 21 135
2020 34 23 160

(a) Which of the foLlowing code snippets will return the MaxTemp and Rainfall for year 2018 and 2019?

(i) Climate[‘MaxTemp’,’Rainfall’][1:3]
(ii) Climate[‘MaxTemp’, ‘Rainfall’][1:3]
(iii) Climate.iloc[(1:3]
(iv) Climate.iloc[1:3,1:2]
Answer:
(iii) Climate.iloc[1:3]

(b) Display the temperature difference between MaxTemp and MinTemp for all the rows in the dataframe Climate.

(i) Climate=Qimate(”MaxTemp”)-Qimate(“MinTemp”)
(ii) print(Climate(“maxt”]-Climate(“mint”])
(iii) print(Qimate[“MaxTemp”]-Climate(“MinTemp”])
(iv) print(Climate.Climate(”MaxTemp”]-Climate(“MinTemp“]) Answer: (iii) print(Climate(“MaxTemp”)-Climate(“MinTemp”])

(c) To display 2 rows from the top in the dataframe, which of the following statement is correct?

(i) print (Climate.head( )=2)
(ii) print (Climate.head(n=2))
(iii) print (Climate.head(range(2)))
(iv) print (Climate.head(2))
Answer:
(iv) print (Climate.head(2))

(d) Which of the following statement/s will give the exact number of values in each column of the dataframe?

(a) print(Climate.count())
(b) print(Climate.count(0))
(c) print(Climate.count)
(d) print(Climate.count(axis=’index’))
Choose the correct option.
(i) Both a. and b.
(ii) only b.
(iii) a. b. and c.
(iv) a. b, and d.
Answer:
(iv) a. b. and d.

(e) To display 2 rows from the bottom in the dataframe, which of the following statement is correct?

(i) print (Climate.tail()=2)
(ii) print (Climate.tail(n=2))
(iii) print(Climate.tail(range(2)))
(iv) print (Climate.tail(2))
Answer:
(iv) print (Climate.tail(2))

Case Study 9

HR Department of ABC Tech has created following dataframe to store data about salaries and bonus paid to their employees: import pandas as pd import numpy as np . dl={‘EName’:[ ‘Kavita’, ‘Sudha’, ‘Garima’]’], ‘Sal’:[50000,60000,5 5000]/ Bonus’:[3000,4000,5000]} Dfl=pd.DataFrame(dl) :
Choose the python statement using suitable functions for the ; following tasks.

(a) Display the columns Sal and Bonus.

(i) dfl [Sal :Bonus]
(ii) dfliloc([‘Sal’,,Bonu5′])
(iii) dfl.iloc([‘Sal’,’Bonus’])
(iv) dfl([‘Sal’,’Bonus’])
Answer:
(ii) df1.loc([‘Sal’,’Bonus’])

(b) Display the details of employee Kavita.

(i) dfl[df1.EName-Kavita’]
(ii) dfl.loc[df1.EName==’Kavita’]
(iii) dfl.iloc[df1.EName=-Kavita’]
(iv) dfl[(EName=’Kavita’]
Answer:
(iv) df1.loc[df1.EName==’Kavita’]

(c) Display the details of the last employee.

(i) Dfl.tail(1)
(ii) Dfl.tail (-1)
(iii) Dfl.head(n=1)
(iv) Dfl.head( )
Answer:
(i) Dfl.tail(1)

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(d) Add a new column named ‘Email’ with the value “abc@ gmail.com”.

(i) Df1[‘Email]= ‘[email protected]
(ii) Df1[Email]=’[email protected]
(iii) Df1.loc[‘Email’]=’[email protected]
(iv) Df1[‘Email’]=’[email protected]
Answer:
(i) Df1[‘Email’]= ‘[email protected]

(e) Write a python statement to print the details of employees having Sal more than 50000.

(i) dfl.Sal>=5000
(ii) dfl(df1.Sal>=5000]
(iii) dfl(df1.’Sal’>=5000]
(iv) dfl.iloc[df1.Sat>=5000)
Answer:
(ii) dfl[dfl.Sal>=5000]

Case Study 10

Consider the dataframe, namely Sdf, given below an answer questions a. to e. StudentID Homework Midterm Project Final

Student ID Homework Midterm Project Final
4560 100 97 100 95
5540 85 90 88 90
6889 92 85 88 87
6817 65 85 87 89

(a) Display only the first three columns of the dataframe.

(i) Sdf.loc[:, :2]
(ii) Sdf.loc[:, :-2]
(iii) Sdf.iloc[, :-2]
(iv) Sdf.iloc[:, :2]
Answer:
(iii) Sdf.iloc[:, :-2]

(b) Which of the following commands will given the output as shown below?

1. 5540 85
2. 6889 92
3. 6817 65

(i) Sdf.loc[1:,: 2]
(ii) Sdf.loc[0 :2]
(iii) 5df.iloc[0:, :2]
(iv) Sdf.iloc[1:, :2]
Answer:
(iv) Sdf.iloc[1:, :2)

(c) The Principal wants to known the details of students who have scored at least 90% in the Final Marks percentage. Which of the following set of commands will yield the desired result?

(i) print (Sdf (‘Final’ >=90))
(ii) print(Sdf [Sdf[‘Final’] =*=90])
(iii) tmp = Sdf [Sdf [‘Final’] >=90] print(tmp)
(iv) Both (iii) and (iv)
Answer:
(iv) Both (iii) and (iv)

(d) The programmer wants to calculate how many students’ details are stored in the dataframe. Which of the following commands will yield the number of records in each column of the dataframe?

(i) Sdf.count(axis = 1)
(ii) pandas.count(Sdf.columns)
(iii) Sdf.count( )
(iv) pandas.count(Sdf)
Answer:
(iii) Sdf.count( ) .

(e) What will the following statement yield? Sdf.Midterm>90

(i) 0 97 True
1 90 False
2 85 False
3 85 False

(ii) 0 True
1 False
2 False
3 False

(iii) 0 97
1 NaN
2 NaN
3 NaN

(iv) Error

Answer:
(ii) 0 True
1 False
2 False
3 False

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

Case Study 11

Consider the following dataframe ndf as show below:

Column 1 Column 2 Column 3 Res
T1 62.893165 100.0 60.00 True
T2 94.734486 100.0 59.22 True
T3 49.090140 100.0 46.04 False
T4 38.487265 85.4 58.62 False

Aswer questions from a. to e.:

(i) Which of the below given commands will yield following output?

(a) Which of the below given commands wiLt yield the following output?

Column1 Column 2 Column 3 Res
T 2 94.734483 100.0 59.22 True
T 3 49.090140 100.0 46.04 False
T 4 38.487265 85.4 58.62 False

(i) print(ndf.iloc(‘T2’:, :])
(ii) print(ndf.at[‘T2’:, :])
(iii) print(ndf.loc[‘T2’:, :])
(iv) print(ndf.iat[‘T2’:, :])
Answer:
(iii) print(ndf.loc[‘T2’:, :])

(b) Predict the output produced by the following statement: Print(ndf.at[‘T3’, ‘Res’], ndf.atpT, ‘Column3’])

(i) False 60
(ii) T3  49.090140  100.0  46.04  False
T1   62.893165      100.0  60.00
(iii) T3    False   T1    60.00
(iv)

Column 1 Column 2 Column 3
T 1 62.893165 100.0 60.00
T 2 94.734483 100.0 59.22
T 3 49.090140 100.0 46.04

Answer:
(ii) T3  49.090140   100.0     46.04    False
T1   62.893165    100.0     60.00

(c) Which command will delete the rows T2 and T3?

(i) ndf.drop(‘T2’, ‘T3’)
(ii) ndf.drop([‘T2’, ‘T3’])
(iii) ndf.drop([‘T2’, ‘T3’], axis = 1)
(iv) ndf.drop([‘T2’, ‘T3’], axis = 1)
Answer:
(ii) ndf.drop([‘T2’, ‘T3’])

(d) Which command will yield the maximum value from the column Column3?

(i) Panda5.max(ndf[‘Column3’])
(ii) max(ndf[‘Column3’])
(iii) ndf(ndf[‘Column3’].max( )]
(iv) ndf[‘Column3’].max( )
Answer:
(iv) ndf[‘Column3’].max( )

(e) Which command will delete columns ‘Column2’ and ‘Res’?

(i) ndf.del ([‘Column2’, ‘Res’])
(ii) ndf.del ([‘Column2’, ‘Res’], axis = 1)
(iii) ndf.drop ([‘Column2’ ‘Res’])
(iv) ndf.drop ([‘Column2’, ‘Res’], axis = 1)
Answer:
(iv) ndf.drop ([‘Column2’, ‘Res’], axis = 1)

Case Study 12

Given a data frame namely data as shown below (fruit names are row labels):

Color Cant Price
Apple Red 3 120
Apple Green 9 110
Pear Red 25 125
Pear Green 26 150
Lime Green 99 70

Answer questions from a. to e.

(a) Which of the below given commands will yield the following output?

Price
Apple 120
Apple 110
Pear 125
Pear 150
Lime 70

(i) data.iloc[: 4, 2 :]
(ii) data.iloc[:, 2:]
(iii) data.loc[: 4, 2:]
(iv) data.loc[:, 2:]
Answer:
(ii) data.iloc[:, 2:]

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(b) Find all rows with the label “Apple”. Extract all columns. (Choose the correct statement)

(i) data.loc[:, ‘Apple’]
(ii) data.iloc[‘Apple’,:]
(iii) data.iloc[:, ‘Apple’]
(iv) data.loc[‘Apple’,:]
Answer:
(iv) data.loc[‘Apple’ :]

(c) List 2nd, 3rd and 4th rows. (Choose the correct statement).

(i) data.loc[0:3,:]
(ii) data.loc[:, 0:3]
(iii) data.iloc[0:3,:]
(iv) data.loc[:, 0:3]
Answer:
(iii) data.iloc[0:3,:]

(d) List the rows having price more than 120. (Choose the correct statement)

(i) data[[‘Price’] > 120]
(ii) data[data[‘Price’] > 120]
(iii) data[ [‘Price’] > 120]
(iv) data[[‘Price’] > 120]
Answer:
(ii) data[data[‘Price’] > 120]

Case Based MCQ Questions for Class 12 Informatics Practices - Python Pandas

(e) List the fruit having the maximum price. (Choose the correct statement).

(i) data[‘Price’].max( )
(ii) data[data[‘Price’].max( )]
(iii) data[data[‘Price’].max( ) = True]
(iv) data[data[‘Price’] = data[‘Price’].max( )]
Answer:
(iv) data[data[‘Price’] = data[‘Price’].max( )]

Assertion-Reason Type Question uestions

Directions: In the Questions given below, there are two statements marked as Assertion (A) and Reason (R). Read the statements and choose the correct option.
(a) Both (A) and (R) are true, and (R) is the correct explanation of (A).
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).
(c) (A) is true, but (R) is false.
(d) (A) is false, but (R) is true.

Question 1.

Assertion (A): Pandas is a popular data-science library of Python.
Reason (R): A series is a Pandas data structure that represents.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 2.

Assertion (A): A Data structure is a Pandas data structure that represents a 2D array like object.
Reason (R): You can use numpy NaN for missing dat(a)

Answer:
(d) (A) is false, but (R) is true.

Question 3.

Assertion (A): To specify datatype for a series object, dtype argument is use(d)
Reason (R): The len( ) function on series object returns total elements in it including NaNs.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 4.

Assertion (A): The count() function on series object returns only the count of non-NaN values in it.
Reason (R): Series is value mutable.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 5.

Assertion (A): Series is not size mutable.
Reason (R): Dataframe is size mutable as well as value mutable.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 6.

Assertion (A): In a dataframe, Axis = 1 represents the column elements.
Reason (R): To access values using row labels you can use DF.open.

Answer:
(c) (A) is true, but (R) is false.

Question 7.

Assertion (A): To access individual value, you can use DF on using row/column index labels.
Reason (R): To access individual value, you can use DF. lat using row/column integer position.

Answer:
(d) (A) is false, but (R) is true.

MCQ Questions for Class 12 Informatics Practices – Python Pandas Part 2

Question 8.

Assertion (A): The rename( ) function requires inplace argument to make changes in the original dataframe.
Reason (R): To access values using row labels you can use DF. lo(c)

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

MCQ Questions for Class 12 Informatics Practices – Python Pandas Part 1

Question 9.

Assertion (A): A Pandas series object can be thought of as a column or a row, essentially.
Reason (R): Both series and dataframe are one-dimensional data structure objects.

Answer:
(c) (A) is true, but (R) is false.

Question 10.

Assertion (A): While series is a one-dimensional data structure object, dataframe is a multi-dimensional data structure object.
Reason (R): A series object is value mutable.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 11.

Assertion (A): A series object is size mutable.
Reason (R): A dataframe value mutable.

Answer:
(d) (A) is false, but (R) is true.

Question 12.

Assertion (A): A dataframe object is size mutable.
Reason (R): There is no difference between NumPy array and a series object.

Answer:
(c) (A) is true, but (R) is false.

Question 13.

Assertion (A): A dataframe can be thought of as a group of : multiple series objects.
Reason (R): A dataframe has similar properties as a series object.

Answer:
(c) (A) is true, but (R) is false.

Question 14.

Assertion (A): In a dataframe, Axis = 1 represents the ; column elements.
Reason (R): To access values using row labels you can use : DF.open.

Answer:
(c) (A) is true, but (R) is false.

Question 15.

Assertion (A): A series object can store only homogeneous ; (same type of) elements. :
Reason (R): A dataframe object can store only homogeneous ; elements.

Answer:
(c) (A) is true, but (R) is false.

Question 16.

Assertion (A): The del statement can remove the rows as j well as columns in a dataframe.
Reason (R): A Pandas series object can be thought of as a ; column or a row, essentially.

Answer:
(d) (A) is false, but (R) is true.

Question 17.

Assertion (A): The rename() always makes changes in the default dataframe.
Reason (R): While series is a one-dimensional data structure object, dataframe is a multi-dimensional data structure object.

Answer:
(d) (A) is false, but (R) is true.

Question 18.

Assertion (A): A series object is value mutable.
Reason (R): A series object can store only homogeneous (same type of) elements.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 19.

Assertion (A): To create an empty Series object,you can use : (d)Series(). :
Reason (R): To specify datatype intl6 for a Series object, : you can write p(d)Series(data = array, dtype = numpy.int 16).

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 20.

Assertion (A): To get the number of dimensions of a series object, ndim attribute is displaye(d) :
Reason (R): To get the size of the datatype of the items in series object, you can display index attribute.

Answer:
(c) (A) is true, but (R) is false.

Question 21.

Assertion (A): To get the number of elements in a series : object, size attribute may be used
Reason (R): To get the number of bytes of the series data,  dtype attribute is displaye(d)

Answer:
(c) (A) is true, but (R) is false.

MCQ Questions for Class 12 Informatics Practices – Python Pandas Part 1

Question 22.

Assertion (A): To check if the series object contains NaN j values, hasnans attribute is displaye(d) ;
Reason (R): To display third element of a series object S, you will write S[2].

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 23.

Assertion (A): To display first three elements of a series object S.you may write S[:3].
Reason (R):To display last five rows of a series object S. you may write head( ).

Answer:
(c) (A) is true, but (R) is false.

Question 24.

Assertion (A): Missing data in Pandas object is represented through NaN.
Reason (R): Given a Pandas series called Sequences, the command which will display the first 4 rows is print(Sequences.head(4)).

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 25.

Assertion (A): If a dataframe is created using a 2D dictionary, then the indexes/row labels are formed from inner dictionary’s keys.
Reason (R): If a dataframe is created using a 2D dictionary, then the column labels are formed from outer dictionary’s keys.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 26.

Assertion (A): The axis 0 identifies a dataframe’s rows.
Reason (R):The axis 1 identifies a dataframe’s columns.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

Question 27.

Assertion (A): To get the number of elements in a dataframe, size attribute may be used
Reason (R): To get NumPy representation of a dataframe, shape attribute may be use)

Answer:
(c) (A) is true, but (R) is false.

Question 28.

Assertion (A): 18. To get NumPy representation of a dataframe, values attribute may be used
Reason (R): To get a number representing number of axes in a dataframe, values attribute may be used

Answer:
(c) (A) is true, but (R) is false.

Question 29.

Assertion (A): To get the transpose of a dataframe Dl, you can write Dl.T.
Reason (R): To extract row/column from a dataframe, loc( ) function may be used

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

MCQ Questions for Class 12 Informatics Practices – Python Pandas Part 1

Question 30.

Assertion (A): To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF, you can write DF.iloc[6:10,3:6].
Reason (R): To change the 5th column’s value at 3rd row as 35 in dataframe DF.you can write DF.iat[3,5] = 35.

Answer:
(b) Both (A) and (R) are true, but (R) is not correct explanation of (A).

MCQ Questions for Class 12 Informatics Practices with Answers

error: Content is protected !!