Skip to content
Question
Q.

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 Celcius) over five days as given in the table:

DaysTemperature
Day 130
Day 232
Day 331
Day 429
Day 528

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:

  1. Write the suitable code to import the required module in the blank space in the line marked as Statement-1.
  2. Fill in the blank in Statement-2 with a suitable Python function name to create a line plot.
  3. Refer to the graph shown and fill in the blank in Statement-3 to display the appropriate label for x-axis.
  4. Refer to the graph shown and fill in the blank in Statement-4 to display the suitable chart title.
CBSECBSE Class XII Board 2025Subjective· 4mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The Python program uses the matplotlib.pyplot module to create a line plot, with plt.plot() drawing the graph, plt.xlabel() labeling the x-axis as 'Days', and plt.title() setting the chart title to 'Daily Temperature'.

Data visualization is a powerful technique for understanding and communicating insights from data. Instead of looking at raw numbers in a table, a visual representation like a line plot allows us to quickly spot trends, patterns, and anomalies. For Gurkirat's task, we are using Python's matplotlib library, which is a fundamental tool for creating static, animated, and interactive visualizations in Python.

A line plot is particularly effective for showing how a variable changes over a continuous range, such as time. In this case, we are tracking temperature changes across five consecutive days. Each point on the line plot represents the temperature on a specific day, and these points are connected by lines to illustrate the progression.

Let's break down the Python code statement by statement to understand its purpose and fill in the blanks.

  • Statement-1: import ______ as plt

    To use the plotting functionalities of Matplotlib, we need to import its pyplot module. It is a common convention to import pyplot and give it the alias plt, which makes the code shorter and easier to read. This module contains functions for creating various types of plots, including line plots, bar charts, and scatter plots.

    Important

    matplotlib.pyplot is the standard module for creating plots in Matplotlib, and plt is its widely accepted alias.

  • Statement-2: plt.______(days, temp)

    After importing the module, the next step is to actually create the line plot. The plt object, which refers to matplotlib.pyplot, has a specific function for drawing line graphs. This function takes two main arguments: the data for the x-axis and the data for the y-axis. In Gurkirat's program, days will be plotted on the x-axis and temp on the y-axis.

  • Statement-3: plt.xlabel('______') …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.