-
-
Save jennyonjourney/c032a1f4e25d4d03e4601b3536f77f92 to your computer and use it in GitHub Desktop.
largest = None | |
smallest = None | |
while True: | |
inp = raw_input("Enter a number: ") | |
if inp == "done" : break | |
try: | |
num = float(inp) | |
except: | |
print ("Invalid input") | |
continue | |
if smallest is None: | |
smallest = num | |
if num > largest : | |
largest = num | |
elif num < smallest : | |
smallest = num | |
def done(largest,smallest): | |
print ("Maximum is", int(largest)) | |
print ("Minimum is", int(smallest)) | |
done(largest,smallest) |
largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
num = int(num)
if largest is None or largest < num:
largest = num
if smallest is None or smallest > num:
smallest = num
except:
print('Invalid input')
continue
print("Maximum is", largest)
print("Minimum is", smallest)
largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
fnum = float(num)
if smallest == None or fnum < smallest:
smallest = num
if largest is None or fnum > largest:
largest = num
except:
print("Invalid input")
continue
print("Maximum is", largest)
print("Minimum is", smallest)
largest = None smallest = None num = 0 while True: num = input("Enter a number: ") if num == "done" : break try: numb = int(num) except: print ("Invalid input") continue if smallest is None: smallest = numb elif numb < smallest : smallest = numb if largest is None: largest = numb elif numb > largest: largest = numb print ("Maximum is", largest) print ("Minimum is", smallest)
This is a correct code. It's absolutely run and match the output.
"Hello, everyone. Could you kindly assist me with this exercise?
I am encountering difficulties, and nothing seems to be effective.
largest = None
smallest = None
while True :
num = input ('Enter a number :')
if num=='done':
break
#elif num =='Done':
#break
try :
fnum = float (num )
except:
print ('Invaild input')
continue
if largest in None:
largest = fnum
elif fnum > largest:
largest = fnum
#print (fnum)
if smallest is None :
smallest =fnum
#print (fnum)
Print ('Maximum is', int(largest))
Print ('Minimum is' , int(smallest)) IS NOT WORKIG
Guys my code is like that and it's working is it true ?
numlist = []
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
num = int(num)
(numlist.append(num))
largest = max(numlist)
smallest = min(numlist)
except:
print("Invalid input")
print("Maximum is", largest)
print("Minimum is", smallest)
please help out