#Assignment 5.2
#Finding the smallest and largest number
largest = None
smallest = None
while True:
num = raw_input("Enter a number: ")
if num == "done" : break
try:
#First input is given to both.
if largest == None: largest = float(num)
if smallest == None: smallest = float(num)
#the smallest and largest changes with new inputs
if smallest > float(num): smallest = float(num)
if largest < float(num): largest = float(num)
except:
print "Invalid input"
continue
print "Maximum is", int(largest)
print "Minimum is", int(smallest)
c= raw_input("Enter to exit...")
#Finding the smallest and largest number
largest = None
smallest = None
while True:
num = raw_input("Enter a number: ")
if num == "done" : break
try:
#First input is given to both.
if largest == None: largest = float(num)
if smallest == None: smallest = float(num)
#the smallest and largest changes with new inputs
if smallest > float(num): smallest = float(num)
if largest < float(num): largest = float(num)
except:
print "Invalid input"
continue
print "Maximum is", int(largest)
print "Minimum is", int(smallest)
c= raw_input("Enter to exit...")
Comments
Post a Comment