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

Python Pandas Class 12 MCQ Questions Part 2

Question 1.

Which of the following statement is correct for importing pandas in python?

(a) import pandas
(b) import pandas as pd
(c) import pandas as pds
(d) All of these
Answer:
(d) All of these

Question 2.

What type of error is returned by following statement? import pandas as pnd pn(d)Series([l,2,3,4], index = [aVb’,’c’])

(a) SyntaxError
(b) IndexError
(c) ValueError
(d) None of these
Answer:
(c) ValueError

Question 3.

Which attribute is used to give user defined labels in Series?

(a) Index
(b) Data
(c) Values
(d) None of these
Answer:
(a) Index

Question 4.

Fill in the blank to get the ouput as 3 import pandas as pnd Sl=pn(d)Series([l,2,3,4], index = [‘a’,’b’,’c’,’d’]) print(Sl[ ])

(a) ‘c’
(b) 2
(c) c
(d) All of these
Answer:
(d) All of these

Question 5.

Write the statement to get NewDelhi as output using positional index, import pandas as pd SI=p(d)Series([‘NewDelhi’,’WashingtonDC’,’London’,’Paris’], index=[‘lndia’, ‘USA’, ‘UK’, ‘France’])

(a) print(S1(0])
(b) print(S1(‘lndia’])
(c) Both of the above
(d) print(Sl.lndia)
Answer:
(a) print(S1(0])

Question 6.

We can access elements in Series by using …… index and index.

(a) Numeric, Labelled
(b) Positional, Naming
(c) Positional, Labelled
(d) None of these
Answer:
(c) Positional, Labelled

Question 7.

Write the output of the following: import pandas as pd
SI = p(d)Series([‘NewDelhi’,’WashingtonDC’, ‘London’, ’Paris’], index=[’lndia’, ‘USA’, ‘UK’, ‘France’]) print(Sl[‘lndia’,’UK’])

(a) India NewDelhi UK London dtype: object
(b) India NewDelhi UK Washington dtype: object
(c) Error
(d) None of these
Answer:
(c) Error

Question 8.

Which of the following statement will print Series ‘SI’ in reverse order?

(a) print(S1(:: 1]
(b) print(S1(:: -1]
(c) print(S1(-1:: 1]
(d) print(S1.reverse())
Answer:
(b) print(S1(:: -1]

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

Question 9.

How many values will be modified by last statement of given code? import pandas as pd
SI=p(d)Series([‘NewDelhi’,’WashingtonDC’,’London’,’Paris’], index=[‘A’, ‘B’, ‘C’, ‘D’]) S1[A’: C’] = ‘ND’

(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(c) 3

Question 10.

How many values will be modified by last statement of given code? import pandas as pd
SI = p(d)Series([’NewDelhi’, ’WashingtonDC’, ‘London’, ‘Paris’], index=[‘A’,’B’,’C’,’D’]) Sl[l: 3] = ‘ND’

(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

Question 11.

Which of the following property/attribute assign name to the Series?

(a) name
(b) index.name
(c) size
(d) Series.name
Answer:
(a) name

Question 12.

Sl.vatues will return all the values of Series ‘SI’ in

(a) Tuple
(b) Dictionary
(c) List
(d) String
Answer:
(c) List

Question 13.

Which of the following property/attribute return total number of values in Series‘SI’?

(a) Size
(b) Values
(c) lindex
(d) None of these
Answer:
(a) Size

Question 14.

Which of the following attributes returns True if there is no value in Series?

(a) Index
(b) Size
(c) Empty
(d) Values
Answer:
(c) Empty

Question 15.

Which of the following attributes returns all the values of Series?

(a) Size
(b) Index
(c) Name
(d) Values
Answer:
(d) Values

Question 16.

Write the output of the following code: import pandas as pd Sl=p(d)Series() print(p(d)Series().empty)

(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True

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

Question 17.

Write the output of the following code : import pandas as pd Sl=p(d)Series([l,2,3,4])
S2=p(d)Series([7,8]) S3=S1+S2 print(S3.size) (a) 2 (c) 6

Answer:
(a) 2
(b) 4
(c) 6
(d) Error
Answer:
(b) 4

Question 18.

Which of the following statement shows first five values of Series ‘SI’?

(a) S1.head( )
(b) S1.head( 5 )
(c) Both of the above
(d) None of these
Answer:
(c) Both of the above

Question 19.

Write the output of the following: import pandas as pd Sl=p(d)Series([l,2,3,4])
S2=p(d)Series([7,8]) print((Sl+S2).count()) .

(a) 6
(b) 4
(c) 2
(d) 0
Answer:
(c) 2

Question 20.

Which of the following returns number of non-NaN values of Series?

(a) count
(b) size
(c) index
(d) values
Answer:
(a) count

Question 21.

Write the output of the following: import pandas as pd Sl=p(d)Series([l,2,3,4])
S2=p(d)Series([7,8,9,10]) S2.index=[‘a’,’b’,’c’,’d’] print{{Sl+S2).count( ))

(a) 8
(b) 4
(c) 0
(d) 6
Answer:
(c) 0

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

Question 22.

We can perform on two series in Pandas.

(a) addition
(b) subtraction
(c) multiplication
(d) All of these
Answer:
(d) All of these

Question 23.

Which of the following method is used to add two series?

(a) sum( )
(b) addition( )
(c) add( )
(d) None of these
Answer:
(c) add( )

Question 24.

Which of the following statement will display the difference of two Series ‘A’ and ‘B’?

(a) >>>A-B
(b) >>>(a)sub(B)
(c) Both of the above
(d) None of these
Answer:
(c) Both of the above

Question 25.

Which of the following fills the missing values in Series?

(a) fill-value
(b) fill-value
(c) fill_value
(d) fill_value( )
Answer:
(c) fill_value

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

Question 26.

Which of the following function is used for basic mathematical operations in Series?

(a) add( )
(b) mul( )
(c) div( )
(d) All of these
Answer:
(d) All of these

Question 27.

Which of the following statement is replacing missing values of Series A and Series B by 100?

(a) >>> (a)add(B, fill_value = 100)
(b) >>>(a)add(B, fill_value : 100)
(c) >>> (a)add(B, fill-value = 100)
(d) >>> (a)add(B, fill-value : 100)
Answer:
(a) >>> A,add(B, fill_value = 100)

Question 28.

Mathematical operations on two Series object is done by matching

(a) indexes
(b) values
(c) Both of the above
(d) None of these
Answer:
(a) indexes

Question 29.

Which of the following statement will display values more ‘ than 40 from Series ‘SI’?

(a) >>>S1
(b) >> SI > 40
(c) >>>S1(S1 > 40]
(d) None of these
Answer:
(c) >>> S1(S1 > 40]

Question 30.

Which of the following statement will return 10 values from the bottom/end of the Series ‘SI’?

(a) S1.tail()
(b) S1.tail(10)
(c) S1.head(10)
(d) S1(10)
Answer:
(b) S1.tail(10)

Question 31.

Which of the following are valid operations on Series ‘SI’?

(a) >>>S1 + 2
(b) >>>S1**2
(c) >>> S1*2
(d) All of these
Answer:
(d) All of these

Question 32.

When an operation is carried out on every value of Series object is called

(a) Scalar operation
(b) Vector operation
(c) Both of the above
(d) None of these
Answer:
(b) Vector operation

Question 33.

Which of the following statement will modify the first three values of Series ‘SI’?

(a) S1[0,1, 2] = 100
(b) S1[0 : 3] = 100
(c) S1[: 3] = 100
(d) All of these
Answer:
(d) All of these

Question 34.

We can have duplicate indexes in Series?

(a) True
(b) False
(c) On
(d) Off
Answer:
(a) True

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

Question 35.

What is the index value of 31 in given Series ‘SI’? import pandas as pd
Sl=p(d)Series([l,2,31,4], index = [’a’.’bVcVd’])

(a) ‘c’
(b) 2
(c) Both of the above
(d) None of these
Answer:
(c) Both of these

Question 36.

S2 is ……..in given code.
S2 = Sl[2 : 5] #S1 is a Series object

(a) list
(b) tuple
(c) series
(d) None of these
Answer:
(c) series

Question 37.

Following two statements will provide the same output:
>>>L1 “ 2 #L1 is a list
>>>S1 “ 2 #S1 is a Series

(a) True
(b) False
(c) On
(d) Off
Answer:
(b) False

Question 38.

Best way to import the pandas module in your program:

(a) import pandas
(b) import pandas as p
(c) from pandas import
(d) All of these
Answer:
(d) All of these

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

Question 39.

Dataframe in pandas is:

(a) 1 dimensional array
(b) 2 dimensional array
(c) 3 dimensional array
(d) None of these
Answer:
(b) 2 dimensional array

Question 40.

For what purpose a Pandas is used?

(a) To create a GUI programming
(b) To create a database
(c) To create a High level array
(d) All of the above
Answer:
(c) To create a High level array

Question 41.

In data science, which of the python library are more popular?

(a) Numpy
(b) Pandas
(c) Open CV
(d) Django
Answer:
(b) Pandas

Question 42.

Minimum number of argument we require to pass in pandas series?

(a) 0
(b) 1
(c) 2
(d) 3
Answer:
(b) 1

Question 43.

Series in Pandas is:

(a) 1 dimensional array
(b) 2 dimensional array
(c) 3 dimensional array
(d) None of these
Answer:(a) 1 dimensional array

Question 44.

Way to install the pandas library?

(a) install pandas
(b) pandas install python
(c) python install pandas
(d) None of these
Answer:
(d) None of these

Question 45.

We can analyse the data in pandas with:

(a) series
(b) dataframe
(c) Both of the above
(d) None of these
Answer:
(c) Both of the above

Question 46.

What we pass in Dataframe in pandas?

(a) Integer
(b) String
(c) Pandas series
(d) All of these
Answer:
(c) Pandas series

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

Question 47.

Choose the correct function to rename city columns to location using rename() function.

(a) df.rename(columns={‘City’:’Location’})
(b) df.rename(columns={‘City’=’Location’})
(c) df.rename(‘City’=’Location’)
(d) df.rename(df.columns(‘City’,’Location’))
Answer:
(a) df.rename(columns={,City’:’Location’})

Question 48.

Which of the following statement(s) is/are correct with respect to df.columns properties to rename columns? All columns must be specified . Columns must be in the form of a list Old column names not required Columns can be specified with columns number

(a) Only 1 is correct
(b) 1, 2 and 3 are correct
(c) 1 and 3 are correct
(d) All of them are correct
Answer:
(b) 1, 2 and 3 are correct

Question 49.

df.index properties ca be used to:

(a) rename rows
(b) rename columns
(c) rename rows and columns both
(d) None of the above
Answer:
(a) rename rows

Question 50.

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

(a) df.head( )=2
(b) df.head(n=2)
(c) df.head(range(2))
(d) All of these
Answer:
(b) df.head(n=2)

Question 51.

A function is used to display top rows (n) from …….. dataframe.

(a) Tail( )
(b) Head( )
(c) Top( )
(d) Header( )
Answer:
(b) Head( )

Question 52.

A function is used to display bottom rows (n) from dataframe.

(a) Tail( )
(b) Head( )
(c) Top( )
(d) Header( )
Answer:
(a) Tail( )

Question 53.

…… refers to passing True and False value as an index in Dataframes.

(a) Ignore_head
(b) Ignore_index
(c) Ignore_tail
(d) Ignore_header
Answer:
(b) ignore_index

Question 54.

To pass index label keyword is used to in p(d)dataframe() function.

(a) index
(b) value
(c) size
(d) empty
Answer:
(a) index

Question 55.

By default you can display……..no. of top/bottom …… rows using head()/tail() function.

(a) four
(b) six
(c) five
(d) seven
Answer:
(c) five

Question 56.

Pandas is an opensource Library?

(a) Ruby
(b) Javascript
(c) Java
(d) Python
Answer:
(d) Python
Pandas is an opensource Python Library providing high- performance data manipulation and analysis tool using its powerful data structures.

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

Question 57.

Pandas key data structure is called:

(a) Keyframe
(b) Dataframe
(c) Statistics
(d) Econometrics
Answer:
(b) Dataframe
Pandas is built on the Numpy package and its key data structure is called the Dataframe.

Question 58.

In pandas, Index values must be:

(a) uniQuestion ue
(b) hashable
(c) Both a and b
(d) None of these
Answer:
(c) Both a and b
Index values must be uniQuestion ue and hashable, same length as dat(a) Default np.arrange(n) if no index is passe(d)

Question 59.

Which of the following is correct features of Dataframe?

(a) Potentially columns are of different types
(b) Can perform Arithmetic operations on rows and columns
(c) Labeled axes (rows and columns)
(d) All of the above

Question 60.

A panel is a container of dat(a)

(a) ID
(b) 2D
(c) 3D
(d) Infinite
Answer:
(c) 3D
A panel is a 3D container of dat(a) The term Panel data is derived from econometrics and is partially responsible for the name pandas : pan(el)-da(ta)-s.

Question 61.

Which of the following is true?

(a) If data is an ndarray, index must be the same length as dat(a)
(b) Series is a one-dimensional labeled array capable of holdihg any data type.
(c) Both a and b
(d) None of the above
Answer:
(c) Both a and b

Question 62.

Which of the following takes a diet of diets or a diet of arraylike sequences and returns a Dataframe?

(a) Dataframe.fromjtems
(b) Dataframe.from_records
(c) Dataframe.from_dict
(d) All of the above
Answer:
(a) Dataframe.fromjtems
Dataframe.from_dict operates like the DataFrame constructor except for the orient parameter which is ‘columns’ by default.

Question 63.

Which of the following makes use of pandas and returns data in a series or dataframe?

(a) panda SDMX
(b) freedapi
(c) OutPy
(d) Inpy
Answer:
(b) freedapi
freedapi module requires a FRED API key that you can obtain for free on the FRED website.

Question 64.

What will be output for the following code? import pandas as pd import numpy as np s – p(d)Series(np.random.randn(4)) print s.ndim

(a) 0
(b) 1
(c) 2
(d) 3
Answer:
(b) 1
Returns the number of dimensions of the object. By definition, a Series is a ID data structure, so it returns 1.

Question 65.

Which of the following indexing capabilities is used as a concise means of selecting data from a pandas object?

(a) In
(b) ix
(c) ipy
(d) iy
Answer:
(b) ix
ix and reindex are 100% eQuestion uivalent.

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

Question 66.

Which of the following thing can be data in Pandas?

(a) a python diet
(b) an ndarray
(c) a scalar value
(d) All of the mentioned
Answer:
(d) all of the mentioned
The passed index is a list of axis labels.

Question 67.

Point out the correct statement.

(a) If data is a list, if index is passed the values in data corresponding to the labels in the index will be pulled out
(b) NaN is the standard missing data marker used in pandas
(c) Series acts very similarly to a array
(d) None of the mentioned
Answer:
(b) NaN is the standard missing data marker used in pandas If data is a diet, if index is passed the values in data corresponding to the labels in the index will be pulled out.

Question 68.

The result of an operation between unaligned Series will have the of the indexes involve(d)

(a) intersection
(b) union
(c) total
(d) All of the mentioned
Answer:
(b) union
If a label is not found in one Series or the other, the result will be marked as missing NaN.

Question 69.

Which of the following input can be accepted by Dataframe?

(a) Structured ndarray
(b) Series
(c) Dataframe
(d) All of the mentioned
Answer:
(d) All of the mentioned
Dataframe is a 2-dimensional labeled data structure with columns of potentially different types advertisement.

Question 70.

Point out the wrong statement.

(a) A Dataframe is like a fixed-size diet in that you can get and set values by index label
(b) Series can be be passed into most NumPy methods expecting an ndarray
(c) A key difference between Series and ndarray is that operations between Series automatically align the data based on label
(d) None of the mentioned
Answer:
(a) A Dataframe is like a fixed-size diet in that you can get and set values by index label
A Series is like a fixed-size diet in that you can get and set values by index label.

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

Question 71.

Which of the following takes a diet of diets or a diet of arraylike sequences and returns a Dataframe?

(a) DataFrame.fromtems
(b) DataFrame.from records
(c) DataFrame.from dict
(d) All of the mentioned
Answer:
(a) DataFrame.fromtems
DataFrame.fromdict operates like the DataFrame constructor except for the orient parameter which is ‘columns’ by default.

Question 72.

Series is a one-dimensional labeled array capable of holding any data type.

(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True
The axis labels are collectively referred to as the index.

Question 73.

Which of the following works analogously to the form of the diet constructor?

(a) DataFrame.fromJtems
(b) DataFrame.from_records
(c) DataFrame.from_dict
(d) All of the mentioned
Answer:
(a) DataFrame.fromJtems
DataFrame.from records takes a list of tuples or an ndarray with structured dtype.

Question 74.

Which of the following operation works with the same syntax as the analogous diet operations?

(a) Getting columns
(b) Setting columns
(c) Deleting columns
(d) All of the mentioned
Answer:
(d) All of the mentioned
You can treat a Dataframe semantically like a diet of like- indexed Series objects.

Question 75.

If data is an array; index must be the same length as dat(a)

(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True
If no index is passed, one will be created having values [0 len(data) -1],

MCQ Questions for Class 12 Informatics Practices with Answers

error: Content is protected !!