Question:

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:

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.
(ii) Fill in the blank in Statement-2 with a suitable Python function name to create a line plot.
(iii) Refer to the graph shown and fill in the blank in Statement-3 to display the appropriate label for x-axis.
(iv) Refer to the graph shown and fill in the blank in Statement-4 to display the suitable chart title.
 

Show Hint

Always use `plot()` for line plots, `xlabel()` and `ylabel()` for axis labels, and `title()` for the chart title in matplotlib.
Updated On: Jul 14, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

(i) The required module to create plots is matplotlib.pyplot.
So the correct import statement is:
import matplotlib.pyplot as plt

This imports the pyplot module and gives it the alias plt.
(ii) To create a line plot, we use the `plot` function.
So the correct statement is:
plt.plot(days, temp)

This plots temperature values against days as a line graph.
(iii) The label for the x-axis, based on the graph, should be Days.
So the statement is:
plt.xlabel('Days')

This correctly labels the x-axis on the graph.
(iv) The title of the chart should be “Temperature Over 5 Days” as shown.
So the statement is:
plt.title('Temperature Over 5 Days')

This displays the chart title above the plot.
Together, these statements complete the line plot code properly.
Was this answer helpful?
0
0

Top Questions on Python Libraries

View More Questions