Page 308 - Touhpad Ai
P. 308
# Add title
plt.title('Distribution of Transportation Modes Used by Commuters')
# Show the plot
plt.show()
Output:
20. Write a Python program using Seaborn to create a histogram showing the distribution of exam scores for 40
students.
import seaborn as sns
import matplotlib.pyplot as plt
# Exam scores of 40 students
scores = [45, 50, 55, 60, 62, 65, 68, 70, 72, 75,
48, 52, 58, 63, 66, 69, 71, 74, 77, 80,
42, 49, 53, 57, 61, 64, 67, 73, 76, 79,
46, 51, 56, 59, 65, 70, 72, 78, 81, 85]
sns.histplot(scores, bins=5, color='skyblue')
plt.title("Histogram of Exam Scores")
plt.xlabel("Scores")
plt.ylabel("Number of Students")
plt.show()
Output:
306 Touchpad Artificial Intelligence - XI

