Data handling class 12 mcq | Informatics Practices MCQ

This post contains Multiple Choice Questions with answers for Data handling class 12 MCQ. This is based on syllabus designed by CBSE for Informatics Practices Class 12. Data handling majorly covers three topics:
Python Series
Python Dataframe
Plotting with pyplot

Python pandas is the library which is mainly used for data handling.

Data handling class 12 mcq Set-4 (Q-76 to 100)

  1. What will be shape of given dataframe?

    5              4              3              2              9
    6              4              6              3              7

    a. (5,2)
    b. (2,5)
    c. (10,)
    d. (2,)

Show Answer

b. (2,5)/p>

  1. Which of the following is correct statement?

    a. inplace argument of rename function is set to False, than original dataframe is changed  with new index/columns.
    b. del statement of dataframe can be used to delete rows.
    c. When a dataframe object is created, all the columns are sorted automatically.
    d. While specifying your own index sequence in DataFrame() function, Python doesn’t care about length of index.

Show Answer

c. When a dataframe object is created, all the columns are sorted automatically.

  1. Which of the following is correct syntax of using DataFrame() for defining a dataframe?

    a. pandas.DataFrame(Data, index, columns, dtype, copy)           
    b. pandas.DataFrame(Data, index, columns, dtype)
    c. pandas.DataFrame(Data, index, columns)      
    d. b and c
    e. All of above

Show Answer

e. All of the above

  1. Find the output of the following code:

    df = pd.DataFrame({‘soap’: pd.Series([23,45,34],[‘A’,’B’,’C’]), ‘salt’ : pd.Series([11,23],[‘A’,’B’]), ‘sugar’:pd.Series([20,54],[‘C’,’D’])})
    print(df)

    a.     soap  salt  sugar
    A  23.0  11.0    NaN
    B  45.0  23.0    NaN
    C  34.0  NaN   20.0
    D  NaN  NaN   54.0

    b. A     B     C     D
    soap   23.0  45.0  34.0   NaN
    salt   11.0  23.0   NaN   NaN
    sugar  NaN  NaN  20.0  54.0

Show Answer

a.     soap  salt    sugar
A     23.0  11.0    NaN
B     45.0  23.0    NaN
C     34.0  NaN   20.0
D    NaN  NaN   54.0

  1. What will be output of 
    print(df.loc[:])

    a. Display ‘Error’
    b. Display all rows
    c. Display all columns
    d. Display all rows and columns

Show Answer

b. Display all rows

  1. Identify the correct statement:

    a. A dataframe can only store homogeneous elements
    b. empty of dataframe counts NaN or NA values
    c. The index of dataframe can be number, letter or string.
    d. Size of dataframe returns total no of rows.

Show Answer

c. The index of dataframe can be number, letter or string.

  1. To access the a value of dataframe using row labels we can use-

    a. at
    b. loc
    c. iat
    d. iloc

Show Answer

a. at

  1. given a dataframe ‘df’ as shown below:
                rollno    name    marks
    0              1        ram       NaN
    1              2        sham     45
    2              3      hari        56
    3              4       krishna 49

    What will output of following code?
    df.count()
a) rollno   4	b)  12	c)  4	d)  rollno  4
   name     4			    name    4
   marks    3			    marks   4

Show Answer

a) rollno   4
   name     4
   marks    3	

  1. Considering following dataframe ‘class’ and state which of the following is not True?
        boys	girls	subject	awards
class1	24	16	5	8
class2	20	20	5	10
class3	18	33	6	13
class4	21	19	6	9

a. class.loc[‘class1’, : ]
b. class.loc[ : , ‘boys’]
c. class.loc[‘class1’]
d. class.loc[‘boys’]

Show Answer

d. class.loc[‘boys’]

  1. Which is true

    a. Pandas supports non-unique index values.
    b. Pandas supports label based indexing
    c. Pandas used range method for implicit indexing.
    d. All are true

Show Answer

d. All are true

  1. A dataframe can be thought of as dictionary of list/series.

    a. True
    b. False

Show Answer

a. True

  1. Which of the following is not parameter of append() method used to merge two dataframes?

    a. Axis
    b. Sort
    c. Verify_intigrity
    d. Ignore_index

Show Answer

a. axis

  1. When a dataframe is created using dictionary of any sequence such as series or list, the resulting index or row labels are ________ of all indexes or labels.

    a. Union
    b. Intersection
    c. Product
    d. Sum

Show Answer

a. union

  1. For a dataframe df[:] = 0 will

    a. Create result set with elements having data equal to 0
    b. Assign 0 to all its elements
    c. Display value of first row and column
    d. Assign value of first row and column

Show Answer

a. Create result set with elements having data equal to 0

  1. For a given dataframe
     coachid	name	rank
A	1	Jack	12
B	2	Kim	3	
C	3	Rajan	4
D	4	Juber	11
E	5	Hanuma	2

When Raja is trying to rename indexes using following code
                df.rename(index=[‘a’,’b’,’c’])
he is getting error. Help him to select correct command to rename columns


a. df.rename(index=[‘a’,’b’,’c’], column = {})
b. df.rename(index={‘A’:‘a’,’B’:’b’,’C’:’c’})
c.  df.rename(index=[‘A’=‘a’,’B’=’b’,’C’=’c’])
d. df.rename(index=(‘a’,’b’,’c’))

Show Answer

b. df.rename(index={‘A’:‘a’,’B’:’b’,’C’:’c’})

  1. find output of given code
           d1 = {‘name’: [‘jai’,’veer’,’shera’], ‘code’ : np.array([102,448,504]), ‘gender’:’m’}
           df6 = pd.DataFrame(d1, index = d1[‘code’])
           print(df6))
a.	
	name  code 	gender
102    	jai   	102      m
448   	veer   	448      m
504  	shera   504      m

b. 
	102	448	504
name   	jai  	veer  	shera
code    102   	448    	504
gender	m     	m      	m

Show Answer

name  code 	gender
102    	jai   	102      m
448   	veer   	448      m
504  	shera   504      m

  1. In boolean Indexing we can filter data in ______ ways.

    a. 1
    b. 2
    c. 3
    d. many

Show Answer

b. 2

  1. To merge two dataframes df1 and df2 with no duplicate row labels, which command should be executed?

    a. df1.append(df2, ignore_index=True)
    b. df1.append(df2,ignore_index= False)
    c. df1.append(df2, verify_intigrity = True)
    d. df1.append(df2, verify_intigrity = False)

Show Answer

c. df1.append(df2, verify_intigrity = True)

  1. For a dataframe with columns eno, ename and salary, shilpa want to add a new column hra which will store 20% of salary. Help her to do this.

    a. df[‘hra’] = df[‘salary]*0.2
    b. df.hra = df.salary * 0.2
    c. df[‘hra’ = df[‘salary’]*0.2]
    d. None

Show Answer

a. df[‘hra’] = df[‘salary]*0.2

  1. The term used to represent row labels in a dataframe is

    a. index
    b. column
    c. row
    d. field

Show Answer

a. index

  1. (a) A dataframe can be created using 2D dictionary whether its inner dictionary have matching keys or not.
    (b) NaN values are automatically filled for values of non-matching keys of inner keys of dictionary used in creating dataframe.

    a. (A) is False but (R) is True
    b. (A) is True but (R) is False
    c. Both are True but (R) is not correct explanation of (A)
    d. Both are True and (R) is correct explanation of (A)

Show Answer

c. Both are True but (R) is not correct explanation of (A)

  1. Consider the following dataframe df created
    bcode  bname   rate	
0   101	   c++	   270
1   102	   java	   430
2   103	   python  NaN
4   104	   dbms	   380
5   105	   mysql   320

Sujeet found that rate of python is missing. So he thought to fill it with 500rs. what command he should write to do so?


a. df.replacena(500)
b. df.fillna = 500
c. df.fillna(500)
d. df.replacena = 500

Show Answer

c. df.fillna(500)

  1. Consider the following dataframe df created
	schools	hospitals  gym
jaipur	120	30	   5
raipur	130	34	   4
nagpur	158	57	   12		
kanpur	144	48	   9

find the sum of all the columns as given below:
 jaipur    155
 raipur    168
 nagpur  227
 kanpur  201


a. df.sum()
b. df.sum(axis = 0)
c. df.sum(axis = 1)
d. df.sum

Show Answer

c. df.sum(axis = 1)

  1. Anil has created a dataframe df which he wants to manage according to given questions.
        EmpNo	Name	Salary
0	E01	raj	1000
1	E02	Sohail	1200
3	E03	Sameer	1800
4	E04	Kunal	1600
5	E05	John	1400	

He wants to arrange and display data based on Name in descending order. What code   he should write?


a. df.sort_values(by = ‘name’, ascending = False)
b. df.sort_values(by = ‘name’, asc = False)
c. df.sort_values(ascending = False)
d. df.sort_values(‘name’,asc = False)

Show Answer

a. df.sort_values(by = ‘name’, ascending = False)

  1. Anil has created a dataframe df which he wants to manage according to given questions.
        EmpNo	Name	Salary
0	E01	raj	1000
1	E02	Sohail	1200
3	E03	Sameer	1800
4	E04	Kunal	1600
5	E05	John	1400	

He wants to find all the records with salary less than 1500. He should write?


a. df.salary(data <=1500)
b. df[df.salary <=1500]
c. df[‘salary’<=1500]
d. None of the above

Show Answer

b. df[df.salary <=1500]

Data handling class 12 MCQ Set-1 (Q1-Q25)

Data handling class 12 MCQ Set-2 (Q26-Q50)

Data handling class 12 MCQ Set-3 (Q51-Q75)

Informatics Practices Class 12 MCQ

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!