हिंदी

Rohan, a business analyst, is working on a Python program to create a line graph that represents the monthly revenue (in lakhs) of a company over five months. - Informatics Practices

Advertisements
Advertisements

प्रश्न

Rohan, a business analyst, is working on a Python program to create a line graph that represents the monthly revenue (in lakhs) of a company over five months. However, some parts of his code are incomplete. Help Rohan by filling in the blanks in the following Python program.

Month Revenue (in Lacs)
January 50
February 65
March 75
April 80
May 95

Help Rohan to complete the code.

______ as plt #Statement−1 
Months = ['January', 'February', 'March', 'April', 'May']
Revenue = [50, 65, 75, 80, 95]
______ #Statement-2
plt.xlabel('Months')
plt.ylabel('Revenue')

______ #Statement-3
______ #Statement-4
plt.legend()
plt.show()

  1. Write the suitable code for the import statement in the blank space in the line marked as Statement−1.
  2. Write the suitable code for the blank space in the line marked as Statement−2, which plots the line graph with the appropriate data and includes a label for the legend.
  3. Fill in the blank in Statement-3 with the correct Python code to set the title of the graph.
  4. Fill in the blank in Statement-4 with the appropriate Python code to save the graph as an image file named monthly_revenue.png.
कोड लेखन
Advertisements

उत्तर

import matplotlib.pyplot as plt
Months = ['January', 'February', 'March', 'April', 'May']
Revenue = [50, 65, 75, 80, 95]
plt.plot(Months, Revenue, label='Revenue (in Lacs')
plt.xlabel('Months')
plt.ylabel('Revenue')

plt.title('Monthly Revenue Analysis')
plt.savefig('monthly_revenue.png')
plt.legend()
plt.show() 

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×