Advertisements
Advertisements
Question
Collect and store data related to the screen time of students in your class separately for boys and girls and present it using a boxplot.
Code Writing
Advertisements
Solution
import pandas as pd
import matplotlib.pyplot as plt
data = {
'Boys': [3, 4, 5, 2, 6, 4, 5],
'Girls': [2, 3, 4, 5, 3, 6, 4]
}
df = pd.DataFrame(data)
print(df)
df.boxplot()
plt.title("Screen Time of Students")
plt.xlabel("Gender")
plt.ylabel("Screen Time (Hours)")
plt.show()
Output:
A box plot will be displayed comparing the screen time of boys and girls in the class. It shows the minimum value, maximum value, median, and spread of screen time data.
shaalaa.com
Is there an error in this question or solution?
