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.
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
Related Questions
Why is from import* statement not recommended for importing Python modules in an external program?
Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following input parameters :
(a) length of box ;
(b) width of box ;
(c) height of box.
Test it by writing complete program to invoke it.
Write a Python program to generate a random number between 0 and 9.
Define a function which accepts n as an argument and prints Fibonacci series till n.