Created
March 2, 2016 13:26
-
-
Save devpruthvi/fd82b2db3dbd86cf34c6 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
import numbers | |
def getNumber(s): | |
try: | |
return int(s) | |
except ValueError: | |
return float(s) | |
flag = True | |
nums = [] | |
while flag: | |
try: | |
num = raw_input('Give a number: ') | |
if(num == "quit"): | |
flag = False | |
elif not isinstance(float(num), numbers.Real): | |
raise Exception | |
else: | |
nums.append(getNumber(num)) | |
except: | |
print('Only numbers are allowed') | |
print('Results:\nMaximum = ' + str(max(nums)) + '\nMinimum = ' + str(min(nums)) + '\nSum = ' + str(sum(nums)) + '\nAverage = ' + str(sum(nums)/len(nums))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment