Learn with Yasir

Share Your Feedback

C. Code Modification Questions (3)


C. Code Modification Questions (3)

Modify the given programs according to the requirements.

Question 9. Change line appearance

Given code:

plt.plot(months, students)

Modify it to:

  • Change the line color to red.
  • Add circular markers.
  • Set line width to 3.

Question 10. Add chart information

Given code:

plt.plot(months, sales)plt.show()

Modify it to:

  • Add title: Monthly Sales Report.
  • Add X-axis label: Month.
  • Add Y-axis label: Sales.
  • Add gridlines.

Question 11. Add a legend and save the chart

Given code:

plt.plot(months, cs_students, label="Computer Science")plt.plot(months, it_students, label="Information Technology")

Modify it to:

  • Display a legend.
  • Display gridlines.
  • Save the chart as department_enrollment.png.