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

error: Content is protected !!