This commit is contained in:
Ryan Whytsell 2023-12-24 14:11:02 -05:00
parent 2d7c0250a5
commit fd0df5dccd
No known key found for this signature in database
GPG Key ID: BD7B18309414DE50
1 changed files with 12 additions and 3 deletions

15
main.py
View File

@ -45,7 +45,6 @@ def get_median():
sorted_state = state
sorted_state.sort()
n = len(sorted_state)
median = 0
if n % 2 == 0:
median = (sorted_state[n // 2 - 1] + sorted_state[n // 2]) / 2
else:
@ -112,6 +111,14 @@ def get_population_standard_deviation():
return std_dev
def get_mean_average_deviation():
global state
mean = get_mean()
n = len(state)
mad = sum(abs(x - mean) for x in state) / n
return mad
def start_shell():
global state
state = []
@ -149,8 +156,10 @@ def handle_input():
case 'pvariance':
print(get_population_variance())
case 'iqr':
lower, upper, range = get_iqr()
print(f"Lower: {lower} - Upper: {upper} - Range: {range}")
lower, upper, iqr = get_iqr()
print(f"Lower: {lower} - Upper: {upper} - Range: {iqr}")
case 'mad':
print(get_mean_average_deviation())
case 'print':
if state is not None:
print(f"{state}")