CBSE Class 11 Computer Science Question 48 of 63

Introduction to Python Modules — Question 17

Back to all questions
17
Question

Question 17

Consider the amount of donations received by a charitable organization given as under:

donations = [100, 60, 70, 900, 100, 200, 500, 500, 503, 600, 1000, 1200]

Now write a Python program to calculate the average amount obtained and median of the above data.

Solution
import statistics
donations = [100, 60, 70, 900, 100, 200, 500, 500, 503, 600, 1000, 1200]
average_amount = statistics.mean(donations)
median_amount = statistics.median(donations)
print("Average amount:", average_amount)
print("Median amount:", median_amount)
Output
Average amount: 477.75
Median amount: 500.0
Answer