CBSE Class 12 Informatics Practices Question 39 of 40

Practice Paper — Question 4

Back to all questions
4
Question

Question 35(a)

The heights of 10 students of eighth grade are given below :

Height_cms = [145, 141, 142, 142, 143, 144, 141, 140, 143, 144] 

Write suitable Python code to generate a histogram based on the given data, along with an appropriate chart title and both axis labels. Also give suitable python statement to save this chart.

Answer
import matplotlib.pyplot as plt
Height_cms = [145, 141, 142, 142, 143, 144, 141, 140, 143, 144] 
plt.hist(Height_cms)
plt.title('Distribution of Heights of Eighth Grade Students')
plt.xlabel('Height (cm)')
plt.ylabel('Frequency')
plt.savefig('heights_histogram.png')
plt.show()
Output
The heights of 10 students of eighth grade are given below : Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12