CBSE Class 12 Informatics Practices Plotting Data using Matplotlib Case Study Questions Set 01

Download CBSE Class 12 Informatics Practices Useful Resources

Explore structured advanced study materials through the CBSE Class 12 Informatics Practices Plotting Data using Matplotlib Case Study Questions Set 01. Tailored for Class 12 learners, utilizing these Informatics Practices resources ensures thorough preparation and strengthens foundational knowledge before final CBSE evaluations.

Access CBSE Study Guides and Summaries

View or download the dedicated CBSE Class 12 Informatics Practices Plotting Data using Matplotlib Case Study Questions Set 01 resource below. Engaging with these advanced study guides under focused conditions ensures continuous academic progress and mastery of the 2026-27 curriculum for Plotting Data using Matplotlib.

Case Study Based Questions

Case Study 1: Mr. Sharma works in the game development industry. He is comparing the ratings of some popular games on the Play Store using the bar chart given below.

Subway SurferTemple RunCandy CrushBottle ShotRunner BestGames012345Rating

He is writing the following code to plot the graph. Help him fill in the blanks to 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]
plt.____________(Games,Rating)       #Statement 2
plt.xlabel("Games")
plt.____________("Rating")           #Statement 3
plt.____________                     #Statement 4
Question 1 (i): Choose the right code for Statement 1.
(a) matplotlib as plt
(b) pyplot as plt
(c) matplotlib.pyplot as plt
(d) matplotlib.plt as pyplot
Show Answer & Explanation

Answer: (c) matplotlib.pyplot as plt

Explanation:
1. The plotting functions bar(), xlabel(), ylabel() and show() belong to the pyplot module of the matplotlib library.
2. The code calls them through the name plt, so the module must be imported as plt.
3. So Statement 1 is import matplotlib.pyplot as plt.

Teacher's Note:
1. pyplot is a sub-module, so it is written as matplotlib.pyplot.
2. plt is only an alias; the code must use the same alias everywhere.

Question 1 (ii): Identify the function that should be used in Statement 2 to plot the above graph.
(a) line()
(b) bar()
(c) hist()
(d) barh()
Show Answer & Explanation

Answer: (b) bar()

Explanation:
1. The chart shows vertical bars, one for each game.
2. Vertical bars are drawn with plt.bar(x, height), so Statement 2 is plt.bar(Games,Rating).
3. barh() would draw horizontal bars, and hist() groups numbers into ranges.

Teacher's Note:
1. Use plot() for a line chart, bar() for a vertical bar chart and hist() for a histogram.
2. There is no line() function in pyplot.

Question 1 (iii): Choose the correct option for Statement 3.
(a) title("Rating")
(b) ytitle("Rating")
(c) ylabel("Rating")
(d) yaxis("Rating")
Show Answer & Explanation

Answer: (c) ylabel("Rating")

Explanation:
1. The word Rating appears along the y-axis of the chart.
2. The y-axis label is set with ylabel(), so Statement 3 is plt.ylabel("Rating").

Teacher's Note:
1. xlabel() and ylabel() label the axes; title() puts a heading above the chart.
2. ytitle() and yaxis() are not pyplot functions.

Question 1 (iv): Choose the right function for Statement 4.
(a) display()
(b) print()
(c) bar()
(d) show()
Show Answer & Explanation

Answer: (d) show()

Explanation:
1. After the chart has been built, plt.show() opens the window and displays it.
2. So Statement 4 is plt.show().

Teacher's Note:
1. print() shows text output, not a chart.
2. To save the chart as an image file instead, use plt.savefig("name.png").

Question 1 (v): If Mr. Sharma wants to change the above plot to any other type of chart, which statement should he change?
(a) Statement 1
(b) Statement 2
(c) Statement 3
(d) Statement 4
Show Answer & Explanation

Answer: (b) Statement 2

Explanation:
1. The type of chart is decided by the plotting function used.
2. That function is in Statement 2 (plt.bar()). Replacing it with, say, plt.plot() gives a line chart.
3. So he should change Statement 2.

Teacher's Note:
1. The labels and the show() call stay the same for every chart type.
2. Only the plotting call (plot, bar, hist) changes the kind of chart.

Case Study 2: Gaurav has written Python code to create the bar plot given below from the following data:

CityHappiness_Index MaleHappiness_Index Female
Delhi6030
Beijing4060
Washington7070
Tokyo6555
Moscow8575
DelhiBeijingWashingtonTokyoMoscowCity01020304050607080Happiness_IndexHappiness Index across cities by genderMaleFemale
import ________ as ______                    #Statement 1
City=['Delhi','Beijing','Washington','Tokyo','Moscow']
Happiness_Index_Male=[60,40,70,65,85]
Happiness_Index_Female=[30,60,70,55,75]
plt.bar([0.25,1.25,2.25,3.25,4.25],Happiness_Index_Male,color='blue',label="Male",width=.5)
plt.______([.75,1.75,2.75,3.75,4.75],Happiness_Index_Female,color='green',width=.5,label="Female")   #Statement 2
pos=range(len(City))
plt.xticks(pos,City,fontsize=10)
plt.xlabel('City',fontsize=16)
plt.ylabel('Happiness_Index',fontsize=16)
________                                     #Statement 3
________                                     #Statement 4
________                                     #Statement 5
Question 2 (i): Identify the suitable code for the blank space in the line marked as Statement 1.
(a) matplotlib as plt
(b) numpy as np
(c) pandas as pd
(d) matplotlib.pyplot as plt
Show Answer & Explanation

Answer: (d) matplotlib.pyplot as plt

Explanation:
1. All the functions in the code (bar, xticks, xlabel, ylabel) are called as plt.something.
2. They belong to the pyplot module, so Statement 1 is import matplotlib.pyplot as plt.

Teacher's Note:
1. The data here are plain Python lists, so neither numpy nor pandas is needed.
2. Importing only matplotlib (option a) does not give direct access to bar().

Question 2 (ii): What is the name of the function to plot the required bar graph in the line marked as Statement 2?
(a) hist()
(b) pie()
(c) bar()
(d) scatter()
Show Answer & Explanation

Answer: (c) bar()

Explanation:
1. Statement 2 draws the second (green) set of bars for the Female values.
2. Bars are drawn with bar(), so the statement is plt.bar([.75,1.75,...],Happiness_Index_Female,...).

Teacher's Note:
1. Calling bar() twice with shifted x positions puts two bars side by side for each city.
2. The width=.5 and the 0.5 shift between the two lists stop the bars from overlapping.

Question 2 (iii): Fill in the blank in Statement 3 to set the chart title as "Happiness Index across cities by gender" with font size 18.
(a) plt.xtitle("Happiness Index across cities by gender",fontsize=18)
(b) plt.title("Happiness Index across cities by gender",fontsize=18)
(c) plt.ytitle("Happiness Index across cities by gender",fontsize=18)
(d) plt.show("Happiness Index across cities by gender",fontsize=18)
Show Answer & Explanation

Answer: (b) plt.title("Happiness Index across cities by gender",fontsize=18)

Explanation:
1. The heading above a chart is set with plt.title().
2. The fontsize argument sets its size, so Statement 3 is plt.title("Happiness Index across cities by gender",fontsize=18).

Teacher's Note:
1. xtitle() and ytitle() do not exist; the axes use xlabel() and ylabel().
2. fontsize works the same way in title(), xlabel(), ylabel() and xticks().

Question 2 (iv): Identify the suitable code for the line marked as Statement 4 to display the legend as shown in the plot.
(a) plt.showlegend()
(b) plt.legend()
(c) plt.display()
(d) plt.show()
Show Answer & Explanation

Answer: (b) plt.legend()

Explanation:
1. Both bar() calls have a label ("Male" and "Female").
2. plt.legend() collects these labels and draws the key box. So Statement 4 is plt.legend().

Teacher's Note:
1. legend() shows nothing unless the plotting calls were given a label.
2. The legend must be added before plt.show() is called.

Question 2 (v): Fill in the blank in Statement 5 to display the plot.
(a) plt.plot()
(b) plt.showplot()
(c) plt.display()
(d) plt.show()
Show Answer & Explanation

Answer: (d) plt.show()

Explanation:
1. The finished chart is displayed with plt.show(), so Statement 5 is plt.show().

Teacher's Note:
1. plt.plot() draws a line chart; it does not display anything by itself.
2. plt.show() is normally the last statement of a plotting program.

Free CBSE Study Guides: Class 12 Informatics Practices Plotting Data using Matplotlib

Comprehensive Study Resources for Plotting Data using Matplotlib

Explore essential learning tools for Class 12 Informatics Practices Plotting Data using Matplotlib. This curated collection features in-depth notes and targeted practice questions built around the active 2026 curriculum to streamline your daily revision.

Understanding Marking Schemes

Built using official NCERT guidelines for Class 12 Informatics Practices, these materials provide reliable academic support. Integrating past examination questions and step-by-step solutions helps students understand official CBSE grading criteria.

Complete Revision for Informatics Practices

Maximize your grade potential by utilizing Class 12 Informatics Practices practice papers in tandem with these structured notes. All printable assignments and interactive mock tests on our platform are updated for the 2026 session and available free of charge.

FAQs

Where can I find the most advanced study material for CBSE Class 12 Informatics Practices for 2026-27?

The latest 2026-27 advanced study resources for Class 12 Informatics Practices are available for free on StudiesToday.com which includes NCERT Exemplars, high-order thinking skills (HOTS) questions, and deep-dive concept summaries.

What does the 2026-27 Informatics Practices study package for Class 12 include?

Our exhaustive Class 12 Informatics Practices package includes chapter wise revision notes, solved practice sheets, important formulas and Concept Maps to help in better understanding of all topics.

Is this study material enough for both CBSE exams and competitive tests?

Yes. For Class 12, our resources have been developed to help you get better marks in CBSE school exams and also build fundamental strength needed for entrance tests including Competency Based learning.

How should Class 12 students use this Informatics Practices material for maximum marks?

in Class 12, students should use Active Recall method, read the concept summary, then solve the Important Questions section without looking at the answers and then check your answers.

Can I download Class 12 Informatics Practices study notes in PDF for offline use?

All CBSE Informatics Practices study materials are provided in mobile-friendly PDF. You can download and save them on your device.

Are the Class 12 Informatics Practices resources updated for the latest NEP guidelines?

Yes, our team has ensured that all Informatics Practices materials for Class 12 are strictly aligned with the National Education Policy (NEP) 2020 and the latest 2026-27 CBSE syllabus.