KnowledgeBoat Logo
|

Computer Science

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.

Python

Python Modules

3 Likes

Answer

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

Answered By

1 Like


Related Questions