CBSESetWise.in

Class 12 Informatics Practices: Data Visualization with Matplotlib PYQs (2022–2026)

Authentic CBSE board questions & official stepwise marking scheme solutions for Data Visualization with Matplotlib (Chapter 2).

Data Visualization with Matplotlib

Matplotlib pyplot line plots, bar charts, histograms, custom labels, title, legends, and savefig() exports.

Key Topics: pyplot.plot(), pyplot.bar(), pyplot.hist(), title and xlabel/ylabel, legend() and savefig()

Download Chapter Booklet PDF (6 Pages)

Data Visualization with Matplotlib Previous Year Questions & Solutions (7 Questions)

Q4 • CBSE 2026 • 1 Mark • Data Visualization with Matplotlib (Chapter 2)

CBSE 2026 Board Examination (Set 4) — Question Q4 (1 Mark) In which scenario is a bar chart preferred over a line chart ? (A) To visualise monthly temperature trends over a year. (B) To compare the number of students in different classes. (C) To show stock price movements over time. (D) To analyse trends in website traffic over days. 1

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2026 1 Mark PYQ Q4
Official CBSE Marking Scheme Solution

(B) To compare the number of students in different classes (1 Mark for writing the correct option)

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2026 1 Mark PYQ Q4 Official Solution
Q33 • CBSE 2026 • 4 Marks • Data Visualization with Matplotlib (Chapter 2)

CBSE 2026 Board Examination (Set 4) — Question Q33 (4 Marks) Ms. Anjali, a data analyst, has been assigned the task of creating a histogram to display the age distribution of ten participants in a workshop. She has been provided with the following list of their ages : Ages = [22, 25, 24, 28, 30, 24, 29, 27, 21, 23] She has started writing a Python program for it. However, the code is incomplete. Help her complete the program by filling in the missing parts, so that the histogram as shown below is displayed. 4 import matplotlib.pyplot as plt Ages = [22, 25, 24, 28, 30, 24, 29, 27, 21, 23] binsize = [20,22,24,26,28,30] plt._______(Ages, bins=binsize, edgecolor = 'black', label = 'Participants') # Statement-1 _____.xlabel('Age') # Statement-2 plt.ylabel('Number of Participants') plt.title("Age Distribution") plt._______ # Statement-3 __________ # Statement-4 Write the suitable code for the blank space in the line marked as Statement-1 which plots the histogram.

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2026 4 Mark PYQ Q33
Official CBSE Marking Scheme Solution

[ CBSE MS Informatics Practices Subject Code 065 Paper Code 90 Class 12 Main 2026 Page: 15/22 ] hist (1 Mark for mentioning hist) Fill in the blank in Statement-2 to use the correct alias of the required module to set the label on x-axis. plt (1 Mark for mentioning plt) Fill in the blank in Statement-3 with the correct Python code to display the legend on the graph. legend() (1 Mark for mentioning legend()) Note: ½ mark to be awarded if legend is mentioned without () Fill in the blank in Statement-4 with the appropriate Python code to display the graph. plt.show() (1 Mark for mentioning plt.show()) Note: ½ mark to be awarded for plt, ½ mark for show(), if plt.show is mentioned without () ½ mark should be awarded

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2026 4 Mark PYQ Q33 Official Solution
Q7 • CBSE 2025 • 1 Mark • Data Visualization with Matplotlib (Chapter 2)

CBSE 2025 Board Examination (Set 4) — Question Q7 (1 Mark) In Python which function of matplotlib library is used to save a plot ? (A) save() (B) saveplot() (C) export() (D) savefig() 1

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 1 Mark PYQ Q7
Official CBSE Marking Scheme Solution

(D) savefig() (1 Mark for writing the correct answer)

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 1 Mark PYQ Q7 Official Solution
Q15 • CBSE 2025 • 1 Mark • Data Visualization with Matplotlib (Chapter 2)

CBSE 2025 Board Examination (Set 4) — Question Q15 (1 Mark) Which of the following libraries defines an ndarray in Python ? (A) pandas (B) numpy (C) matplotlib (D) scipy 1

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 1 Mark PYQ Q15
Official CBSE Marking Scheme Solution

(B) numpy (1 Mark for writing the correct answer)

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 1 Mark PYQ Q15 Official Solution
Q33 • CBSE 2025 • 4 Marks • Data Visualization with Matplotlib (Chapter 2)

CBSE 2025 Board Examination (Set 4) — Question Q33 (4 Marks) Gurkirat has to fill in the blanks in the given Python program that generates a line plot as shown below. The given line plot represents the temperature (in degree Celsius) over five days as given in the table : Days Temperature Day 1 30 Day 2 32 Day 3 31 Day 4 29 Day 5 28 4 [ CBSE MS Informatics Practices Subject Code 065 Paper Code 90 Class 12 Main 2025 Page: 16/24 ] ​ import ______ as plt # Statement-1 days = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] temp = [30, 32, 31, 29, 28] plt.__(days, temp) # Statement-2 plt.xlabel('______') # Statement-3 plt.ylabel('Temperature') plt.title('_____') # Statement-4 plt.show() Write the missing statements according to the given specifications : (i) Write the suitable code to import the required module in the blank space in the line marked as Statement-1.

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 4 Mark PYQ Q33
Official CBSE Marking Scheme Solution

import matplotlib.pyplot as plt #Statement 1 (ii) Fill in the blank in Statement-2 with a suitable Python function name to create a line plot. plt.plot(days,temp) #Statement 2 (iii) Refer to the graph shown and fill in the blank in Statement-3 to display the appropriate label for x-axis. plt.xlabel('Days') #Statement 3 (iv) Refer to the graph shown and fill in the blank in Statement-4 to display the suitable chart title. plt.title('Temperature over 5 days') #Statement 4 (1 mark for writing each correct missing part of statement)

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2025 4 Mark PYQ Q33 Official Solution
Q35 • CBSE 2024 • 4 Marks • Data Visualization with Matplotlib (Chapter 2)

CBSE 2024 Board Examination (Set 4) — Question Q35 (4 Marks) (a) The inventory management software of a grocery shop stores the price of all fruits as follows: Fruits=['Apple','Guava','Papaya','Grapes','Mango'] Price=[l50,70,50,30,120] Write suitable Python code to generate a Bar Chart on the given data. Also add the chart title and label for X and Y axis. Also add suitable statement to save this chart with the name fruits.png. 5

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2024 4 Mark PYQ Q35
Official CBSE Marking Scheme Solution

Page 21/23 (a) import matplotlib.pyplot as plt #Statement 1 Fruits=['Apple','Guava','Papaya','Grapes','Mango'] #Statement 2 Price=[150,70,50,30,120] #Statement 3 plt.bar(Fruits,Price) #Statement 4 plt.title("Fruits Prices") #Statement 5 plt.xlabel("Fruits") #Statement 6 plt.ylabel("Price") #Statement 7 plt.savefig("fruits.png") #Statement 8 CBSE AISSCE 2024 Marking Scheme for Informatics Practices (Sub Code: 065 Paper Code 90) SET-4 Page 22/23 plt.show() #Statement 9 OR Any other equivalent code (½ Mark for writing correct Statement 1) (½ Mark for writing correct Statement 2) (½ Mark for writing correct Statement 3) (1 Mark for writing correct Statement 4) (½ Mark for writing correct Statement 5) (½ Mark for writing correct Statement 6) (½ Mark for writing correct Statement 7) (½ Mark for writing correct Statement 8) (½ Mark for writing correct Statement 9) OR (b) Write suitable Python code to draw the following line chart "CO2 Emission" having title and label for X and Y axis as shown below. Also give suitable Python statement to save this chart with the name, emission.png. (b) import matplotlib.pyplot as plt #Statement 1 month=["April", "May", "June", "July", "August"] #Statement 2 percent=[40,50,30,60,20] #Statement 3 plt.plot(month, percent) #Statement 4 plt.title("Month wise CO2 emission") #Statement 5 plt.xlabel("Month") #Statement 6 plt.ylabel("Percentage") #Statement 7 plt.savefig("emission.png") #Statement 8 plt.show() #Statement 9 OR Any other equivalent code (½ Mark for writing correct Statement 1) (½ Mark for writing correct Statement 2) (½ Mark for writing correct Statement 3) (1 Mark for writing correct Statement 4) (½ Mark for writing correct Statement 5) CBSE AISSCE 2024 Marking Scheme for Informatics Practices (Sub Code: 065 Paper Code 90) SET-4 (½ Mark for writing correct Statement 6) (½ Mark for writing correct Statement 7) (½ Mark for writing correct Statement 8) (½ Mark for writing correct Statement 9)

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2024 4 Mark PYQ Q35 Official Solution
Q33 • CBSE 2023 • 4 Marks • Data Visualization with Matplotlib (Chapter 2)

CBSE 2023 Board Examination (Set 4) — Question Q33 (4 Marks) Consider the following graph. Write the Python code to plot it. Also add the Title, label for X and Y axis. Use the following data for plotting the graph smarks=[10,40,30,60,55] sname=["Sahil","Deepak","Anil","Ravi","Riti"] 5

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2023 4 Mark PYQ Q33
Official CBSE Marking Scheme Solution

Ans import matplotlib.pyplot as plt smarks=[10,40,30,60,55] sname=["Sahil","Deepak","Anil","Ravi","Riti"] plt.plot(sname,smarks) plt.title("Marks secured by students in Term - 1") plt.xlabel('Student Name') plt.ylabel('Marks Scored') plt.show() - 17 of 20- CBSE AISSCE 2023 Marking Scheme for Informatics Practices ies ⅀HEFG (Sub Code: 065 Paper Code 90) SET-4 (1 Mark for import statement) (1 Mark for plot()) (1 Mark for title) (1 Mark for labels) (1 Mark to display) OR Write Python code to draw the following bar graph representing the total sales in each quarter. Add the Title, Label for X-axis and Y-axis. Use the following data for plotting the graph: sales=[450,300,500,650] qtr=["QTR1","QTR2","QTR3","QTR4"] 5 Ans import matplotlib.pyplot as plt #----------------------------# sales=[450,300,500,650] # ignore as part qtr=["QTR1","QTR2","QTR3","QTR4"] #----------------------------# plt.bar(qtr,sales) plt.title("Sales each quarter") plt.xlabel("Quarter") plt.ylabel("Sales") plt.show() (1 mark for import statement) (1 mark for bar()) (1 mark for title) (1 mark for labels) - 18 of 20- CBSE AISSCE 2023 Marking Scheme for Informatics Practices ies ⅀HEFG (Sub Code: 065 Paper Code 90) SET-4 (1 mark to display) SECTION - E

CBSE Class 12 Data Visualization with Matplotlib (Chapter 2) 2023 4 Mark PYQ Q33 Official Solution

Other Informatics Practices Chapters

Data Handling using Pandas • Data Visualization with Matplotlib • Database Query using SQL • Introduction to Computer Networks • Societal Impacts