Data Visualisation with Matplotlib: Class 12 PYQs 2024–2026 with solutions
All 5 CBSE board questions asked from Data Visualisation with Matplotlib in 3 board papers, with the year, set and marks of each. 5 are solved free below. The Class 12 Informatics Practices PYQ Book: Solved Board Papers 2024-2026 (CBSE) has every solution, all chapters and 3 full board papers.
Data Visualisation with Matplotlib: board weightage
Board weightage 2024–2026
| Year | 2024 | 2025 | 2026 |
|---|---|---|---|
| Questions | 1 | 2 | 2 |
| Marks | 5 | 5 | 5 |
Most asked topics
5 questions from 3 papers. Repeated questions are shown once with every year they were asked.
1 mark: MCQ and Assertion–Reason
In which scenario is a bar chart preferred over a line chart? (A) monthly temperature trends (B) comparing the number of students in different classes (C) stock price movements over time (D) website traffic over days
Solution
(B): comparing categories; the other options are trends over time (line charts).
Which function of matplotlib is used to save a plot? (A) save() (B) saveplot() (C) export() (D) savefig()
Solution
(D) savefig().
4 marks: SQL / case-based
Complete the histogram program for Ages = [22, 25, 24, 28, 30, 24, 29, 27, 21, 23], bins [20,22,24,26,28,30]: Statement-1 plot; Statement-2 alias for xlabel; Statement-3 legend; Statement-4 display.
Solution
import matplotlib.pyplot as plt(½ mark is deducted when () is missing after legend/show.)
Ages = [22, 25, 24, 28, 30, 24, 29, 27, 21, 23]
binsize = [20, 22, 24, 26, 28, 30]
plt.hist(Ages, bins=binsize, edgecolor='black',
label='Participants') # Statement-1: hist
plt.xlabel('Age') # Statement-2: plt
plt.ylabel('Number of Participants')
plt.title("Age Distribution")
plt.legend() # Statement-3
plt.show() # Statement-4
Complete the line-plot program (temperatures 30, 32, 31, 29, 28 over Day 1–Day 5): Statement-1 import; Statement-2 function; Statement-3 x-label; Statement-4 title.
Solution
import matplotlib.pyplot as plt # Statement-1
days = ['Day 1','Day 2','Day 3','Day 4','Day 5']
temp = [30, 32, 31, 29, 28]
plt.plot(days, temp) # Statement-2
plt.xlabel('Days') # Statement-3
plt.ylabel('Temperature')
plt.title('Temperature over 5 days') # Statement-4
plt.show()
5 marks: programs and case studies
(a) Fruits = ['Apple','Guava','Papaya','Grapes','Mango'], Price = [150, 70, 50, 30, 120]: generate a bar chart with title and axis labels, and save it as fruits.png.
OR (b) OR: draw the line chart "CO2 Emission" (April–August: 40, 50, 30, 60, 20 %) with title and axis labels, and save it as emission.png.
Solution
import matplotlib.pyplot as plt
Fruits = ['Apple','Guava','Papaya','Grapes','Mango']
Price = [150, 70, 50, 30, 120]
plt.bar(Fruits, Price)
plt.title("Fruits Prices")
plt.xlabel("Fruits")
plt.ylabel("Price")
plt.savefig("fruits.png")
plt.show()
OR
import matplotlib.pyplot as plt
month = ["April", "May", "June", "July", "August"]
percent = [40, 50, 30, 60, 20]
plt.plot(month, percent)
plt.title("Month wise CO2 emission")
plt.xlabel("Month")
plt.ylabel("Percentage")
plt.savefig("emission.png")
plt.show()
Get every solution for all chapters
- Every board question of every chapter, each fully solved the way the board gives marks
- 3 complete board papers, each followed by its solutions
- Weightage and most-asked topics for every chapter
- Instant PDF download, colour and black & white print copies
Revising the chapter first? Complete Informatics Practices Notes for Class 12 (CBSE 065, 2026-27) →
What you get in the pack
- CBSE Class 12 Informatics Practices board papers 2024 to 2026 (3 full board papers)
- All 9 chapters and 3 board papers complete
- Part A: all 9 chapters, questions sorted chapter-wise and by marks
- Year-wise weightage table and most-asked topics for every chapter
- Part B: each full board paper followed by its complete solutions
- Pandas, Matplotlib and SQL answers verified by running the code
- Only the current syllabus in Part A
All chapters in this pack
- PYQ Ch 1 Pandas Series
- PYQ Ch 2 DataFrame: Creation and Attributes
- PYQ Ch 3 DataFrame Operations and CSV Files
- PYQ Ch 4 Data Visualisation with Matplotlib
- PYQ Ch 5 SQL Revision and Single-row Functions
- PYQ Ch 6 SQL Aggregates, Grouping and Joins
- PYQ Ch 7 Computer Networks
- PYQ Ch 8 Introduction to the Internet and Web
- PYQ Ch 9 Societal Impacts
- Board Paper 2026 Set 90 with Solutions
- Board Paper 2025 Set 90 with Solutions
- Board Paper 2024 Set 90 with Solutions
