Worksheets › Class 12 › Plotting Data using Matplotlib
Class 12 · Informatics Practices worksheetPlotting Data using Matplotlib
CBSE Informatics Practices. Line plots, bar charts and histograms, labels, titles, legends, colours, markers and line styles, saving a plot, and the pandas plot function. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.
Sample questions
Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.
Section A · multiple choice
- 1.
The usual way to import the plotting module of Matplotlib is:
- import pyplot.matplotlib
- include matplotlib
- import matplotlib as pd
- import matplotlib.pyplot as plt
Answer
(d) import matplotlib.pyplot as plt
- 2.
Which function would you use to draw a chart of the number of students in each house of a school?
- plt.bar()
- plt.scatter()
- plt.pie()
- plt.barh()
Answer
(a) plt.bar()
- 3.
Which statement shows a box naming each line by its label?
- plt.show()
- plt.xticks()
- plt.xlabel()
- plt.legend()
Answer
(d) plt.legend()
Section B · short answer
- 4.
What is the purpose of plotting data?
Answer
To show data as a picture so that trends, comparisons, patterns and unusual values can be seen and understood quickly.
- 5.
How many bars in this chart are taller than 37? import matplotlib.pyplot as plt x = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] h = [21, 49, 36, 34, 37] plt.bar(x, h) plt.show()
Answer
1
heights above 37: 49
Section C · long answer
- 6.
Write a program to plot the marks of a student in five subjects as a bar chart with a title, axis labels and red bars.
Answer
import matplotlib.pyplot as plt sub = ['Maths', 'Science', 'English', 'Hindi', 'IP'] marks = [78, 85, 69, 74, 90] plt.bar(sub, marks, color='red') plt.title('Marks in Term 1') plt.xlabel('Subject') plt.ylabel('Marks') plt.show()
lists (1); bar with colour (1); title and labels (1); show (1)
Fresh sheets for your child
In the app, every Plotting Data using Matplotlib sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.
Coming soon for Android and iPhone.