-
-
Save jennyonjourney/c032a1f4e25d4d03e4601b3536f77f92 to your computer and use it in GitHub Desktop.
[Coursera] Python for everybody 5.2 Assignment
This file contains 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
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) |
rovesoul
commented
Oct 14, 2023
via email
您的来信已经收到,谢谢。待我尽快上线处理。
——董汇标
您的来信已经收到,谢谢。待我尽快上线处理。
——董汇标
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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment