generated from sdcst11/025-group-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmean.py
32 lines (26 loc) · 829 Bytes
/
mean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def isfloat(number):
try:
float(number)
return True
except ValueError:
return False
def mean():
num = []
print("This calculator will help you calculate the mean from a set of numbers\nEnter as many numbers as you want and type exit when you have finished! :D")
while True:
total = 0
y = 0
x = input("Enter a number: ")
if isfloat(x):
x = float(x)
num.append(x)
elif x.lower() == "exit" and num != []:
for y in range(len(num)):
total += num[y]
mean = total/len(num)
print(f"the total sum of your input is {total}, the mean is {mean}")
break
if not isfloat(x):
print("Invalid input")
if __name__ == "__main__":
mean()