MCQ Questions

Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib

Informatics Practices Class 12 Notes – Plotting Data Using Matplotlib

→ Data Visualisation: It refers to the graphicalor visual representation of information and data using visual elements like charts, graphs and maps, etc. The purpose of plotting data is to visualize variation or show relationships between variables.

→ Pyplot of Matplotlib Library: The matplotlib is a Python library that provides many interfaces and functionality for 2D – graphics similar to MATLAB’s in various forms. It provides both a very quick way to visualize data from Python and publication – quality figures in many formats.

→ Pyplot: It is a collection of methods within matplotlib which allows. user to construct 2D plots easily and interactively.
MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

→ Installing and Importing Matplotlib: It can be installed using the following pip command from the command prompt:
pip install matplotlib

→ For plotting using Matplotlib, we need to import its pyplot module using the following command:
import matplotlib.pyplot as pit

→ Plot ( ): The pyplot module of matplotlib contains a collection of functions that can be used to work on a plot. The plot() function of the pyplot module is used to create a figure.

→ Figure: A figure is the overall window where the outputs of pyplot functions are plotted. A figure contains a Notes plotting area, legend, axis labels, ticks, title, etc.

→ Chart Types: We can create different types of graphs and charts using Pyplot. Some commonly used charts types are:

→ Line Chart: A line chart or line graph is a type of chart which displays information as a series of data points called ‘markers’ connected by straight line segments. With pyplot, a line chart is created using plot() function.

→ Bar Chart: A bar chart or bar graph is a chart or graph that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. With pyplot, a bar chart is created using bar( ) and barh( ) functions.

→ Scatter Plot: The scatter plot is similar to a line chart, the major difference is that while line graph connects the data points with a line, scatter chart simply plots the data points to show the trend in the data. With pyplot, a scatter chart is created using scatter( ) function.

→ Pie Chart: A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. With pyplot, a pie chart is created using pie( ) function. But pie chart can plot only one data sequence unlike other chart types.

→ Histogram Plot: A histogram is a type of graph that provides a visual interpretation of numerical data by indicating the number
of data points that lie within a range of values. With pyplot, a histogram is created using hist( ) function.

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

→ Boxplot Chart: A boxplot is the visual representation of the statistical five number summary of a given data set. With pyplot, a boxplot is created using boxplot ( ) function.’

Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 1a
Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 2a
Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 3a
Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 4a
→ List of pyplot functions to plot different charts:

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

plot (\*args[, scalex, scaley, data])Plot x versus y as lines and/or markers. Make a bar plot.
bar(x, height!, width, bottom, align, data])Make a bar plot.
boxplot(x[, notch, sym, vert, whis, …])Make a box and whisker plot.
hist(x[, bins, range, density, weights, …])Plot a histogram.
pie(x[, explode, labels, colors, autopct, …])Plot a pie chart.
scatter(x, y[, s, c, marker, cmap, norm, …])A scatter plot of x versus y.

→ Marker: A marker is any symbol that represents a data value in a line chart or a scatter plot. In other words, the data points being plotted on a graph/chart are called markers.

markerdescriptionmarkerdescription
‘.’point marker‘H’hexagon2 marker
‘,’pixel marker‘1’Tri _down marker
‘o’circle marker‘2’tri_up marker
‘+’plus marker‘3’tri_ left marker
‘x’x marker‘4’tri_right marker
‘D’diamond marker‘V’triangle_down marke
‘d’thin_diamond marker‘A’triangle_up marker
‘s’pentagon marker‘<‘triangle- left marker
‘P’star marker‘>’triangle_right marker
‘h’hexagonl marker ‘l’ ‘-‘vline, hline markers

→ Colour: It is also possible to format the plot further by changing the colour of the plotted data. We can either use character codes or the colour names as values to the parameter colour in the plot( ).

charactercolourcharactercolour
‘b’blueyyellow
‘g’green‘k’black
‘r’red‘c’cyan
‘m’magentaWwhite

→ Linewidth and Linestyle: The linewidth and linestyle property can be used to change the width and the style of the line chart. Linewidth is specified in pixels. The default line width is 1 pixel showing a thin line. Thus, a number greater than 1 will output a thicker line depending on the value provided.

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib
Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 5a

→ We can also set the linestyle of a line chart using the linestyle parameter. It can take a string such as “solid”, “dotted”, “dashed” or”dashdot”.
Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib 6a

→ The Pandas Plot Function: The plot() method of Pandas accepts a considerable number of arguments that can be used to plot a variety of graphs. It allows customising different plot types by supplying the kind keyword arguments.
Syntax: plt.plot(kind),where kind accepts a string indicating the type of .plot

Kind =Plot TypeKind =Plot Type
lineLine plot (default)boxBoxplot
barVertical bar plotAreaArea plot
barhHorizontal bar plotPiePie plot
HistHistogramscatterScatter plot

MCQ Questions for Class 12 Informatics Practices with Answers

Class 12 Informatics Practices Notes – Plotting Data Using Matplotlib Read More »

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

Plotting Data Using Matplotlib Class 12 Case Based MCQ Questions

Case Study 1
Customising the Plot: Data visualisation demand much more from a graph/plot. The graph or plot should have a proper title, X & Y limits defined, labels, legends et(c) All this make understanding the plot and taking the decision easier. Any graph or chart that you create using matplotlib’s PyPlot interface is created as per a specific structure of a plot or shall we say a specific anatomy. Pyplot charts have hierarchical structures or in simple words they are actually like containers containing multiple items/things inside it.

(a) refers to study of bodily structures (or parts) of something.

(i) Anatomy
(ii) Figure
(iii) Axes
(iv) None of these
Answer:
(i) Anatomy

(b) Pyplot, by default, plots every chart into an area called

(i) Figsize
(ii) Figure
(iii) Title
(iv) Axes
Answer:
(ii) Figure

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

(c) The are individual points marked on X-axis and Y-axis.

(i) Limits
(ii) Axis Label
(iii) Tick_Marks
(iv) Legends
Answer:
(iii) Tick_Marks

(d)………. are the different colours that identify different sets of data plotted on the plot.

(i) Legends
(ii) Axes
(iii) Figure
(iv) None of these
Answer:
(i) Legends

(e)………defines the range of values and number of values marked on X-axis & Y-axis.

(i) Tick_Marks
(ii) Axes
(iii) Axis Label
(iv) Limits
Answer:
(iv) Limits

Case Study 2

Mr. Sharma is working in a game development industry and he was comparing the given chart on the basis of the rating of the various games available on the play store.
MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib 1A
He is trying to write a code to plot the graph. Help Mr. Sharma to fill in the blanks of the code and get the desired output.
import #Statement 1
Games=[“Subway Surfer”,”Temple Run”,”Candy Crush”,”Bottle Shot”,”Runner Best”]
Rating=[4.2,4.8,5.0,3.8,4.1]
pit. (Games,Rating) #Statement 2
pit.xlabel(“Games”)
pit. (“Rating”) #Statement 3
pit. #Statement 4

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

(i) matplotlib as pit
(ii) pvplot as pit
(iii) matplotli(b)pyplot as pit
(iv) matplotli(b)pit as pyplot
Answer:
(iii) matplotli(b)pyplot as pit

(b) Identify the name of the function that should be used in statement 2 to plot the above graph.

(i) line( )
(ii) bar( )
(iii) hist( )
(iv) barh( )
Answer:
(ii) bar()

(c) Choose the correct option for the statement 3.

(i) title(”Rating”)
(ii) ytitle(“Rating”)
(iii) ylabel(“Rating”)
(iv) yaxis(“Rating”)
Answer:
(iii) ylabel(“Rating”)

(d) Choose the right function/method from the following for the statement 4.

(i) display( )
(ii) print( )
(iii) bar( )
(iv) show( )
Answer:
(iv) snow( )

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

(e) In case, Mr. Sharma wants to change the above plot to any other shape, which statement should he change?

(i) Statement 1
(ii) Statement 2
(iii) Statement 3
(iv) Statement 4
Answer:
(ii) Statement 2

Case Study 3

Gaurav has written a Python Code to create a bar plot as given below using the following data:

CityHappiness_Index

male

Happiness_Index

Female

Delhi6030
Beijing4060
Washington7070
Tokyo6555
Moscow8575

Happiness Index across cities by Gender
MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib 1B
Delhi Beijing Washington Tokyo Moscow

City
import………as ……….#Statement 1
City=[‘Delhi’,’Beijing'(Washington “Tokyo’,’Moscow’]
Gender=[‘Male’,’Female’] Happiness_!ndex_
Male=[60,40,70,65,85]
HappinessJndex_Female=[30,60,70,55,75]
plt.bar([0.2 5,1.2 5,2.2 5,3.2 5,4.2 5],H a ppiness_lnd.ex_
Male,color=’blue’,label-‘ Male”,width=.5)
pit. ………..([.75,1.75,2.75,3.75,4.75],Happiness_lndex_
Female,color=’Green’,w idth=.5,label=”Female”) #Statement 2 pos=range(len(City)) print(pos)
plt.xticks(pos,City,fontsize=10) plt.xlabel(‘City’, fontsize=16)
plt.ylabel(‘Happiness_lndex’,fontsize=16)
………….. #Statement 3
…………. #Statement 4
………….#Statement 5

(a) Identify the suitable code to be used in the blank space in line marked as Statement 1.

(i) matplotlib as pit
(ii) numpy as np
(iii) pandas as pd
(iv) matplotli(b)pyplot as pit
Answer:
(iv) matplotli(b)pyplot as pit

(b) What is the name of the function to plot the required bar graph in the line marked as Statement 2?

(i) hist( )
(ii) pie( )
(iii) bar( )
(iv) scatter( )
Answer:
(iii) bar()

(c) Fill in the blank in statement 3 to set Chart Title as “Happiness Index across cities by gender “and font size as 18.

(i) plt.xtitle(“Happiness gender”, fontsize=18) Index across cities by
(ii) plt.title(”Happiness gender”, fontsize=18) Index across cities by
(iii) plt.ytitle(“Happiness gender”,fontsize=18) Index across cities by
(iv) plt.show(“Happiness Index across cities by gender”, fontsize=18)

Answer:
(ii) plt.titlef’Happiness Index across cities by gender”,fontsize=18)

(d) Identify the suitable code for line marked as Statement 4 to display the legends as shown in the plot.

(i) plt.showlegend( )
(ii) plt.legend( )
(iii) plt.display ( )
(iv) plt.show()
Answer:
(ii) plt.legendO

(e) Fill in the blank marked in Statement 5 to display the plot.

(i) plt.plot( )
(ii) plt.showplot( )
(iii) plt.display( )
(iv) plt.show( )
Answer:
(iv) plt.show( )

Assertion-Reason Type Questions

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): A histogram is a plot that shows the underlying frequency distribution of a set of continuous data
Reason (R): Pyplot interface is a collection of methods within matplotlib library of Python.

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

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

Question 2.

Assertion (A): Pyplot’s plot() function is used to create line charts.
Reason (R): Pyplot’s barh( ) function is used to create horizontal bar charts.

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

Question 3.

Assertion (A): Pyplot’s scatter() function is used to create scatter charts.
Reason (R): Pyplot’s hist( ) function is used to createn histogram.

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

Question 4.

Assertion (A): The datapoints plotted on a graph are called markers.
Reason (R): The width argument of plot( ) specifies the width for the line.

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

Question 5.

Assertion (A): The linestyle argument of plot( ) specifies the style of the line.
Reason (R): The line argument of bar() specifies the bar width.

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

Question 6.

Assertion (A): The xticks() function is used to specify ticks for x-axis.
Reason (R): To save a plot, savefig() function is used.

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

Question 7.

Assertion (A): The orientation argument of hist() is set to create a horizontal histogram.
Reason (R): The showmeans argument shows the arithmetic mean on a boxplot.

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

Question 8.

Assertion (A): The notch argument in a boxplot() creates a notched boxplot.
Reason (R): The loc argument of legend( ) provides the location of legend.

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

Question 9.

Assertion (A): Using Python Matplotlib, histogram can be used to count how many values fall into each interval.
Reason (R): Pyplot’s barh() function is used to create line chart.

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

Question 10.

Assertion (A): Statement import pyplot.matplotlib is a valid statement for working on pyplot functions.
Reason (R): By default, pie chart is printed in elliptical or oval shape.

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

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

Question 11.

Assertion (A): The axes define the area (mostly rectangular in shape for simple plots) on which actual plot (line or bar or graph et(c)) will appear. Axis have properties like label, limits and tick marks on them.
Reason (R): A Boxplot is the visual representation of a statistical 5 number summary of a given data set.

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

Question 12.

Assertion (A): A marker is any symbol that represents a data value in a line chart or a scatter plot. In other words, the data points being plotted on a graph/chart are called markers.
Reason (R): The linewidth and linestyle property can be used to change the width and the style of the bar chart.

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

Question 13.

Assertion (A): A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion.
Reason (R): Histogram is a type of graph that provides a visual interpretation of numerical data by indicating the number of data points that lie within a range of value.

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

Question 14.

Assertion (A): Data visualisation demand much more from a graph/plot. The graph or plot should have a proper title, X & Y limits defined, labels, legends et(c)
Reason (R): Any graph or chart that you create using matplotlib’s PyPlot interface is created as per a specific structure of a plot or shall we say a specific anatomy.

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

Question 15.

Assertion (A): Patterns, trends and correlations that might go undetected in text-based data can be exposed and recognised easier with data visualisation techniques or tools such as Line chart, bar chart, pie chart, histogram, scatter chart, etc
Reason (R): Thus, with data visualisation tools, information can be processed in efficient manner and hence better decisions can be made.

Answer:
(a) Both (A) and (R) are true, and (R) is the correct explanation of (A).

Question 16.

Assertion (A): When we plot multiple ranges on a single plot, it becomes necessary that legends are specified. Recall that a legend is a colour or mark linked to a specific data range plotted.
Reasons (R): bar( ) function is used to plot vertical bar graph while barh( ) function is used to plot horizontal bar graph.

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

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

Question 17.

Assertion (A): Pyplot is a collection of methods within matplotlib library (of Python) which allows user to construct 2D plots easily and interactively.
Reason (R): A histogram is a statistical tool used to summarise discrete or continuous dat(a) It provides a visual interpretation of numerical data by showing the numbeY of data points that fall within a specified range of values (called “bins”).

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

Question 18.

Assertion (A): A frequency polygon is a type of frequency distribution graph. In a frequency polygon, the number of observations is marked with a single point at the midpoint of an interval.
Reason (R): The histogram chart is a graph of plotted points that show the relationship between two sets of dat(a) With a scatter plot, a mark or marker (usually a dot or small circle), represents a single data point.

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

Question 19.

Assertion (A): Histogram is a type of graph that provides a visual interpretation of numerical data by indicating the number of data points that lie within a range of value.
Reasons (R): The loc argument of legend() provides the Location of Legend.

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

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib

Question 20.

Assertion (A): Patterns, trends and correlations that might go undetected in text-based data can be exposed and recognised easier with data visualisation techniques or tools such as line chart, bar chart, pie chart, histogram, scatter chart, etc
Reasons (R): A marker is any symbol that represents a data value in a line chart or a scatter plot. In other words, the data points being plotted on a graph/chart are called markers.

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

MCQ Questions for Class 12 Informatics Practices with Answers

Case Based MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Read More »

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Plotting Data Using Matplotlib Class 12 MCQ Questions Part 2

Question 1.

A line chart can be plotted using pyplot library’s plot( ) function.

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

Question 2.

A bar chart can be plotted using pyplot library’s bar( ) function.

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

Question 3.

A bar chart can be plotted using pyplot library’s barh( ) function.

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

Question 4.

It is not possible to plot multiple series of values in the same bar graph.

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

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 5.

A standard marker of representing a non-number data in Python libraries is NaN.

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

Question 6.

If the linestyle argument is missing along with marker style string in a plot( ), a scatter type chart get created

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

Question 7.

The bar( ) function can also create horizontal bar charts.

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

Question 8.

the pie( ) function tan plot multiple data series.

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

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 9.

The plot is always as per the data series being plotted irrespective of the xlim( ).

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

Question 10.

FreQuestion uency polygon is created from histogram.

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

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 11.

The plot method on Series and DataFrame is just a simple wrapper around

(a) gplt.plot( )
(b) plt.plot( )
(c) plt.plotgraph( )
(d) None of the mentioned
Answer:
(b) plt.plot( )
If the index consists of dates, it calls gcf().autofmt_xdate() to try to format the x-axis nicely,

Question 12.

Point out the correct combination with regards to kind keyword for graph plotting.

(a) ‘hist’ for histogram
(b) ‘box’ for boxplot
(c) ‘area’ for area plots
(d) All of the mentioned
Answer:
(d) All of the mentioned
The kind keyword argument of plot( ) accepts a handful of values for plots other than the default Line plot,

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 13.

Which of the following value is provided by kind keyword for barplot?

(a) bar
(b) kde
(c) hexbin
(d) None of the mentioned
Answer:
(a) bar
bar can also be used for barplot.

Question 14.

You can create a scatter plot matrix using the ……. method in pandas.tools.plotting.

(a) sca_matrix
(b) scatter_matrix
(c) DataFrame.plot
(d) All of the mentioned
Answer:
(b) scatter_matrix
You can create density plots using the Series/DataFrame. plot.

Question 15.

Point out the wrong combination with regards to kind keyword for graph plotting.

(a) ‘scatter’ for scatter plots .
(b) ‘kde’ for hexagonal bin plots
(c) ‘pie’for pie plots
(d) None of the mentioned
Answer:
(b) ‘kde’ for hexagonal bin plots kde is used for density plots.

Question 16.

Which of the following plots are used to check if a data set or time series is random?

(a) Lag
(b) Random
(c) Lead
(d) None of the mentioned
Answer:
(a) Lag
Random data should not exhibit any structure in the lag plot.

Question 17.

Plots may also be adorned with error bars or tables.

(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True
There are several plotting functions in pandas.tools.plotting.

Question 18.

Which of the following plots are often used for checking randomness in time series?

(a) Autocausation
(b) Autorank
(c) Autocorrelation
(d) None of the mentioned
Answer:
(c) Autocorrelation
If the time series is random, such autocorrelations should be near zero for any and all time-lag separations.

Question 19.

………….plots are used to visually assess the uncertainty of a statistic

(a) Lag
(b) RadViz
(c) Bootstrap
(d) None of the mentioned
Answer:
(c) Bootstrap
Resulting plots and histograms are what constitutes the bootstrap plot.

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 20.

Andrews curves allow one to plot multivariate data

(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True
Curves belonging to samples of the same class will usually be closer together and form larger structures.

Question 21.

Which is a python package used for 2D graphics?

(a) matplotlibpyplot
(b) matplotlibpip
(c) matplotlibnumpy
(d) matplotlibplt
Answer:
(a) matplotlibpyplot

Question 22.

Identify the package manager for Python packages, or modules.

(a) Matplotlib
(b) PIP
(c) plt.show( )
(d) python package
Answer:
(b) PIP

Question 23.

Read the following code: Identify the purpose of this code and choose the right option from the following: C:\Users\YourName\AppData\Local\Programs\Python\ Python36-32\Scripts>pip – version

(a) Check if PIP is Installed
(b) Install PIP
(c) Download a Package
(d) Check PIP version
Answer:
(a) Check if PIP is Installed

Question 24.

Read the following code: Identify the purpose of this code and choose the right option from the following: C:\Users\Your
Name\AppData\Local\Programs\Python\ Python36-32\Scripts>pip list

(a) List installed packages
(b) List command
(c) Install PIP
(d) Packages installed
Answer:
(a) List installed packages

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 25.

To install matplotlib, the following function will be typed in your command prompt. What does Trepresents? Python -m pip install -U pip

(a) downloading pip to the latest version
(b) upgrading pip to the latest version
(c) removing pip
(d) upgrading matplotlib to the latest version
Answer:
(b) upgrading pip to the latest version

Question 26.

Observe the output figure. Identify the coding for obtaining this output.

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2 1
(a) import matplotli(b)pyplot as pit plt.plot([1,2,3], [4.5,1]) plt.show( )
(b) import matplotli(b)pyplot as pit plt.plot((1,2],[4,5]) plt.show( )
(c) import matplotli(b)pyplot as pit . plt.plot([2,3],[5,1]) plt.show( )
(d) import matplotli(b)pyplot as pit plt.plot([1,3),[4,1]) plt.show( )
Answer:
(a) import matplotli(b)pyplot as pit plt.plot([1,2,3),[4,5,1]) plt.show( )

Question 27.

Which key is used to run the module?

(a) F6
(b) F4
(c) F3
(d) F5
Answer:
(d) F5

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 28.

Identify the right type of chart using the following hints.
Hint 1: This chart is often used to visualize a trend in data over intervals of time.
Hint 2: The line in this type of chart is often drawn chronologically.

(a) Line chart
(b) Bar chart
(c) Pie chart
(d) Scatter plot
Answer:
(a) Line chart

Question 29.

Read the statements given below. Identify the right option from the following for pie chart:
Statement A: To make a pie chart with Matplotlib, we can use the plt.pie() function.
Statement B: The autopct parameter allows us to display the percentage value using the Python string formatting.

(a) Statement A is correct
(b) Statement B is correct
(c) Both the statements are correct
(d) Both the statements are wrong
Answer:
(c) Both the statements are correct

Question 30.

Which library is the most used visulization library in python?

(a) visual
(b) matlibplot
(c) matplotlib
(d) matlab
Answer:
(c) matplotlib .

Question 31.

Recommanded way to load matplotlib library is:

(a) import matplotli(b)pyplot as pit
(b) import matplotli(b)pyplot
(c) import matplotlib as pit
(d) import matplotlib
Answer:
(a) import matplotli(b)pyplot as pit

Question 32.

which function of matplotlib can be used to create a line chart?

(a) line
(b) plot
(c) graph
(d) bar
Answer:
(b) plot

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 33.

Which function can be used to export generated graph in matplotlib to png?

(a) savefigure
(b) savefig
(c) save
(d) export
Answer:
(b) savefig

Question 34.

Which one of these is not a valid line style in matplotlib?

(a) ‘<‘
(b) ‘<‘
(c) ‘<‘
(d) ‘<‘
Answer:
(d) ‘<’

Question 35.

Which one of these is not a type of network graph?

(a) Weighted graph
(b) Directed graph
(c) Undirected graph
(d) Circular graph
Answer:
(d) Circular graph

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 36.

Which graph should be used if we want to show distribution of elements?

(a) pie
(c) bar
Answer:
(d) histogram

Question 37.

Which graph should be data?

(a) bar
(b) basemap
(c) scatterplots
(d) histogram
Answer:
(c) scatterplots

Question 38.

Which method can be networkx library?

(a) shortest_path
(b) short_path
(c) shortestPath
(d) sortPath
Answer:
(a) shortest_path

Question 39.

In box plot, data will be divided in how many parts?

(a) 3
(b) 4
(c) 2
(d) as many as we want
Answer:
(b) 4

Question 40.

Which of the following is the representation of information in a graphic format?

(a) Info graphics
(b) Graphics
(c) Dashboard
(d) Charts
Answer:
(a) Info graphics

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 41.

Which of the following translate complex ideas and concepts into a simple visual format?

(i) Data visualization
(ii) Dashboards
(iii) Tables
(iv) Maps

(a) i.iii
(b) iii, i
(c) i, iv
(d) i, ii
Answer:
(d) i, ii

Question 42.

The most popular data visualization library in Python is:

(a) matplotlib
(b) pip
(c) matinfolib
(d) matpiplib
Answer:
(d) matpiplib

Question 43.

Matplotlib allows you to create a:

(a) Table
(b) Charts
(c) Maps
(d) Info graphics
Answer:
(a) Table

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 44.

Which of following is not a visualization under matplotlib?

(a) Scatter plot
(b) Table plot
(c) Histogram
(d) Box plot
Answer:
(b) Table plot

Question 45.

Which plot displays the distribution of data based on the five number summary?

(a) Scatter plot
(b) Line plot
(c) Box plot
(d) Chart plot
Answer:
(c) Box plot

Question 46.

Which of the following command is used to install matplotlib for codingt?

(a) import plt.matplotlib as plot
(b) import plot.matplotlib as pit
(c) import matplotli(b)pit as plot
(d) import matplotli(b)pyplot as pit
Answer:
(d) import matplotli(b)pyplot as pit

Question 47.

Which of the following method will be add inside the file to display plot?

(a) show ( )
(b) display ( )
(c) execute ( )
(d) plot ( )
Answer:
(a) show ( )

Question 48.

The default x.vector has the same length of y but starts with:

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

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 49.

Which button will help to navigate the chart?

(a) Navigate
(b) Pan
(c) Home
(d) Zoom
Answer:
(c) Home

Question 50.

The different kinds of plot created using:

(a) Matplotlib
(b) Matplot
(c) Plotlib
(d) Matliplot
Answer:
(a) Matplotlib

Question 51.

Which type of chart shows the relationship between a numerical variable and categorical variable?

(a) line
(b) bar
(c) pie
(d) x-y plot
Answer:
(b) bar

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2

Question 52.

Which of the following one indicates discontinuity?

(a) Histogram
(b) Pie
(c) Bar graph
(d) None of these
Answer:
(c) Bar graph

Question 53.

………….. is the graphical representation of information and data

(a) Data visualization
(b) Data graphics
(c) Data dimension
(d) Data images
Answer:
(a) Data visualization

MCQ Questions for Class 12 Informatics Practices with Answers

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 2 Read More »

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Plotting Data Using Matplotlib Class 12 MCQ Questions Part 1

Question 1.

Pyplot is an interface of Python’s …….. library.

(a) seaborn
(b) plotly
(c) ggplot
(d) matplotlib
Answer:
(d) matplotlib

Question 2.

For 2D plotting using a Python library, which library interface is often used?

(a) Seaborn
(b) Plotly
(c) Matplotlib
(d) Matplotli(b)pyplot
Answer:
(d) Matplotli(b)pyplot

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 3.

Which of the following is not a valid chart type?

(a) Histogram
(b) Statistical
(c) Pie
(d) Box
Answer:
(b) Statistical, (d) Box

Question 4.

Which of the following is not a valid plotting function of pyplot?

(a) plot( )
(b)bar( )
(c) line( )
(d) pie( )
Answer:
(c) line( )

Question 5.

Which of the following plotting functions does not plot multiple data series?

(a) plot( )
(b) bar( )
(c) pie( )
(d) barh( )
Answer:
(c) pie( )

Question 6.

The plot which tells the trend between two graphed variables is the graph/chart.

(a) line
(b) scatter
(c) bar
(d) pie
Answer:
(a) line

Question 7.

The plot which tells the correlation between two variables which may not be directly related is graph/chart.

(a) line
(b) scatter
(c) bar
(d) pie
Answer:
(b) scatter

Question 8.

(a) ……. is a summarisation tool for discrete or ….. continuous dat(a)

(a) quartile
(b) histogram
(c) mean
(d) median
Answer:
(b) histogram

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 9.

A visual representation of the statistical five number summary of a given dataset is known as

(a) histogram
(b) frequency distribution
(c) boxplot
(d) frequency polygon
Answer:
(c) boxplot

Question 10.

Which of the following function is used to create a line chart?

(a) line( )
(b) plot( )
(c) chart( )
(d) plotline( )
Answer:
(b) plot( )

Question 11.

Which of the following function will produce a bar chart?

(a) plot( )
(b) bar( )
(c) plotbar( )
(d) barh( )
Answer:
(b) bar( ), (d) barh( )

Question 12.

Which of the following will create a vertical bar chart?

(a) plot( )
(b) bar( )
(c) plotbar( )
(d) barh( )
Answer:
(b) bar( )

Question 13.

Which of the following function will create a horizontal bar chart?

(a) plot( )
(b) bar( )
(c) plotbar( )
(d) barh( )
Answer:
(d) barh( )

Question 14.

To specify the style of line as dashed, which argument of plot( ) needs to be set?

(a) line
(b) width
(c) style
(d) linestyle
Answer:
(d) linestyle

Question 15.

The datapoints plotted on a graph are called

(a) points
(b) pointers
(c) marks
(d) markers
Answer:
(d) markers

Question 16.

A ………. graph is a type of chart which displays …….information as a series of data points connected by straight line segments.

(a) line
(b) bar
(c) pie
(d) boxplot
Answer:
(a) line

Question 17.

To create scatter charts using plot( ), which argument is skipped?

(a) marker
(b) linestyle
(c) markeredgecolor
(d) linewidth
Answer:
(b) linestyle

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 18.

In scatter( ), which argument is used to specify the size of datapoints?

(a) size
(b) s
(c) marker
(d) markersize
Answer:
(b) s

Question 19.

Which argument of bar( ) lets you set the thickness of bar?

(a) thick
(b)thickness
(c) width
(d) barwidth
Answer:
(c) width

Question 20.

Which function Lets you set the title of the plot?

(a) title( )
(b) plottitle( )
(c) graphtitle( )
(d) All of these
Answer:
(a) title( )

Question 21.

The command used to give a heading to a graph is……….

(a) plt.show( )
(b) plt.plot( )
(c) plt.xlabel( )
(d) plt.title( )
Answer:
(d) plt.title( )

Question 22.

Which function would you use to set the limits for x-axis of the plot?

(a) limits( )
(b) xlimits( )
(c) xlim( )
(d) lim( )
Answer:
(c) xlim( )

Question 23.

Which function is used to show legends?

(a) display( )
(b) show( )
(c) legend( )
(d) legends( )
Answer:
(c) legend( )

Question 24.

Which argument must be set with plotting functions for legend() to display the legends?

(a) data
(b) label
(c) name
(d) sequence
Answer:
(b) label

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 25.

Which function is used to create a histogram?

(a) histo( )
(b) histogram( )
(c) hist( )
(d) histtype
Answer:
(c) hist( )

Question 26.

Which argument in hist( ) is used to create a stacked bar type histogram?

(a) histt
(b) histtype
(c) type
(d) barstacked
Answer:
(b) histtype

Question 27.

Which of the following functions can plot only one data series?

(a) plot( )
(b) bar( )
(c) boxplot( )
(d) pie( )
Answer:
(d) pie( )

Question 28.

Which argument must be provided to create wedges out of a pie chart?

(a) label
(b) autopct
(c) explode
(d) wedge
Answer:
(c) explode

Question 29.

Which argument should be set to display percentage share of each pie on a pie chart?

(a) label
(b) autopct
(c) explode
(d) wedge
Answer:
(b) autopct

Question 30.

Which function creates a boxplot?

(a) box( )
(b) plot( )
(c) boxplot( )
(d) showbox( )
Answer:
(c) boxplot( )

Question 31.

Which argument of boxplot( ) is used to create a filled boxplot?

(a) fill
(b) box
(c) patch_artish
(d) patch
Answer:
(c) patch_artish

Question 32.

(a) ……… is a plot that shows the underlying …… frequency distribution of a set of continuous data

(a) Histogram
(b) Pyplot
(c) Bar chart
(d) Pie chart
Answer:
(a) Histogram

Question 33.

Pyplot interface is a collection of methods within library of Python.

(a) Matplotlib
(b) Numpy
(c) Pandas
(d) None of these
Answer:
(a) Matplotlib

Question 34.

Pyplot’s ……… function is used to create line charts.

(a) plot( )
(b) barh( )
(c) scatter( )
(d) hist( )
Answer:
(a) plot( )

Question 35.

Pyplot’s function is used to create horizontal bar charts.

(a) plot( )
(b) barh( )
(c) scatter( )
(d) hist( )
Answer:
(b) barh( )

Question 36.

Pyplot’s function is used to create scatter ……..charts.

(a) plot( )
(b) barh( )
(c) scatter( )
(d) hist( )
Answer:
(c) scatter( )

Question 37.

Pyplot’s function is used to create histogram.

(a) plot( )
(b) barh( )
(c) scatter( )
(d) hist( )
Answer:
(d) hist( )

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 38.

The datapoints plotted on a graph are called

(a) markers
(b) linewidth
(c) linestyle
(d) width
Answer:
(a) markers

Question 39.

The argument of plot( ) specifies the width ……..for the line.

(a) notch
(b) linewidth
(c) linestyle
(d) length
Answer:
(b) linewidth

Question 40.

The argument of plot( ) specifies the style of …… the line.

(a) notch
(b) linewidth
(c) linestyle
(d) length
Answer:
(c) linestyle

Question 41.

The argument of bar( ) specifies the bar …….. width.

(a) markers
(b) linewidth
(c) linestyle fc- V
(d) width
Answer:
(d) width

Question 42.

The function is used to specify ticks for x-axis.

(a) xticks( )
(b) yticks( )
(c) xyticks( )
(d) xxticks( )
Answer:
(a) xticks( )

Question 43.

To save a plot……… function is used

(a) savefig( )
(b) savefun( )
(c) savefigure( )
(d) None of these
Answer:
(a) savefig( )

Question 44.

The argument of hist( ) is set to create a …….. horizontal histogram.

(a) landscape
(b) portrait
(c) documentation
(d) orientation
Answer:
(d) orientation

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 45.

The argument shows the arithmetic mean …… on a boxplot.

(a) showmeans
(b) Showsmeans
(c) Showmean
(d) None of these
Answer:
(a) showmeans

Question 46.

The ……..argument in a boxplot( ) creates a …… notched boxplot.

(a) notch
(b) limits
(c) grid
(d) labels
Answer:
(a) notch

Question 47.

The …… argument of legend( ) provides the …… location of legend

(a) loc
(b) Toe
(c) Goc
(d) None of these
Answer:
(a) loc

Question 48.

Using Python Matplotlib can be used to ……. count how many values fall into each interval.

(a) Histogram
(b) Pyplot
(c) Bar chart
(d) Pie chart
Answer:
(a) Histogram

Question 49.

Pyplot is a sub-library of matplotlib library.

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

Question 50.

Statement import pyplotmatplotlib is a valid statement for working on pyplot functions.

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

Question 51.

By default, pie chart is printed in elliptical or oval shape.

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

Question 52.

The default shape of pie chart cannot be changed from oval

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

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1

Question 53.

A line chart can be plotted using pyplot library’s line( ) function.

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

MCQ Questions for Class 12 Informatics Practices with Answers

MCQ Questions for Class 12 Informatics Practices – Plotting Data Using Matplotlib Part 1 Read More »

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

NameUT1UT2UT3UT4
1. Prerna Singh24242022
2. Manish  Arora18171922
3. Tanish Goel20221824
4. Falguni Jain22202420
5. Kanika Bhatnagar15201822
6. Ramandeep Kaur20152224

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

YearMonthPassengers
02010Jan 25
12010Mar 50
22012Jan 35
32010Dec 55
42012Dec 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.

YearMonthPassengers
Air India2010Jan 25
Indigo2010Mar 50
Spicejet2012Jan 35
Jet2010Dec 55
Emirates2012Dec 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.

HouseFirstSecondThird
0.      Chenab576
1.      Canges1054
2.      Jamuna81315
3.      Jhelum12912
4.      Ravi51110
5.      Satluj1053

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:

NameMarks 1Marks 2
1 Swapnil Sharma3b50
2 Raj Batra7545
3 Bhoomi Singh8595
4 Jay Gupta9095

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

YearMaxTempMinTempRainfall
20173220123
20183322140
20193521135
20203423160

(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 IDHomeworkMidtermProjectFinal
45601009710095
554085908890
688992858887
681765858789

(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. 554085
2. 688992
3. 681765

(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 1Column 2Column 3Res
T162.893165100.060.00True
T294.734486100.059.22True
T349.090140100.046.04False
T438.48726585.458.62False

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?

Column1Column 2Column 3Res
T 294.734483100.059.22True
T 349.090140100.046.04False
T 438.48726585.458.62False

(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 1Column 2Column 3
T 162.893165100.060.00
T 294.734483100.059.22
T 349.090140100.046.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):

ColorCantPrice
AppleRed3120
AppleGreen9110
PearRed25125
PearGreen26150
LimeGreen9970

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

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

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

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

error: Content is protected !!