Python videos
Advertisement

Modules: Exercises and Solutions

Some simple statistics

Exercise

Use the statistics module to calculate the mean of all prime numbers below 10.

Solution

import statistics

prime_numbers = [1, 3, 5, 7]
m = statistics.mean(prime_numbers)
print('M = {0}'.format(m))

Output:

M = 4