Worksheets › Class 12 › Plotting Data using Matplotlib

Class 12 · Informatics Practices worksheet

Plotting 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.

Open a printable sample sheet

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. 1.

    The usual way to import the plotting module of Matplotlib is:

    1. import pyplot.matplotlib
    2. include matplotlib
    3. import matplotlib as pd
    4. import matplotlib.pyplot as plt
    Answer

    (d) import matplotlib.pyplot as plt

  2. 2.

    Which function would you use to draw a chart of the number of students in each house of a school?

    1. plt.bar()
    2. plt.scatter()
    3. plt.pie()
    4. plt.barh()
    Answer

    (a) plt.bar()

  3. 3.

    Which statement shows a box naming each line by its label?

    1. plt.show()
    2. plt.xticks()
    3. plt.xlabel()
    4. plt.legend()
    Answer

    (d) plt.legend()

Section B · short answer

  1. 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.

  2. 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

  1. 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.

More Class 12 Informatics Practices