Last active
May 25, 2024 18:05
-
-
Save jmangrad/8aa25d1cd21b564eb0457114441e5d8b to your computer and use it in GitHub Desktop.
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
Write another program that prompts for a list of numbers | |
as above and at the end prints out both the maximum and minimum of | |
the numbers instead of the average. | |
largest = None | |
smallest = None | |
count = 0 | |
total = 0 | |
while True: | |
try: | |
number = input("Enter a number: ") | |
if number == "done": | |
break | |
number = int(number) | |
count +=1 | |
total =number + total | |
if largest == None and smallest == None: | |
largest = number | |
smallest = number | |
if largest == None or number > largest: | |
largest = number | |
if smallest == None or number < smallest: | |
smallest = number | |
except: | |
print("Invalid input") | |
print("The maximum number is: {}".format(largest)) | |
print("The minimum number is: {}".format(smallest)) | |
print("The total number is: {}".format(total)) | |
print("The count number is: {}".format(count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did mine like this, I hope it helps...