Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
import sys
|
||||
|
||||
def get_next_input():
|
||||
try:
|
||||
num = int(input("Enter rainfall int, 99999 to quit: "))
|
||||
except:
|
||||
print("Invalid input")
|
||||
return get_next_input()
|
||||
return num
|
||||
|
||||
current_average = 0.0
|
||||
current_count = 0
|
||||
|
||||
while True:
|
||||
next = get_next_input()
|
||||
|
||||
if next == 99999:
|
||||
sys.exit()
|
||||
else:
|
||||
current_count += 1
|
||||
current_average = current_average + (1.0/current_count)*next - (1.0/current_count)*current_average
|
||||
|
||||
print("New average: ", current_average)
|
||||
Loading…
Add table
Add a link
Reference in a new issue