Created
June 13, 2021 06:25
-
-
Save islandjoe/8ec8009aa75f3fd1505bcb728904ff40 to your computer and use it in GitHub Desktop.
Python Exercises: Get the min, avg, and max of a list of numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figures = [79250913.5716, 48142828.4666, 41386999.2223, 93411238.6832, 15514669.4931, 70598005.1982, 33304295.9951, 75789282.3759, 74542259.467, 20922976.4366, 42697744.5193, 43535355.1567] | |
from statistics import median | |
min_stat, max_stat, avg_stat = min(figures), max(figures), median(figures) | |
print(f"min: {min_stat}\nmax: {max_stat}\navg: {avg_stat}") | |
min: 15514669.4931 | |
max: 93411238.6832 | |
avg: 45839091.81165 | |
from itertools import tee | |
from statistics import median | |
min_stat, max_stat, avg_stat = tee(figures, 3) | |
print(f"min: {min(min_stat)}\nmax: {max(max_stat)}\navg: {median(avg_stat)}") | |
min: 15514669.4931 | |
max: 93411238.6832 | |
avg: 45839091.81165 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment