-
-
Save jklmli/975758 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
print("type integers, each followed by Enter; or ^D or ^Z to finish") | |
total = 0 | |
count = 0 | |
while True: | |
try: | |
line = input() | |
if line: | |
number = int(line) | |
total += number | |
count += 1 | |
except ValueError as err: | |
print(err) | |
continue | |
except EOFError: | |
break | |
if count: | |
print("count = %i" % count, "total = %i" % total, "mean = %f" % (total/count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment