Created
July 1, 2019 16:40
-
-
Save wafiqsyed/67cfa19684f4878012647e0ece1df980 to your computer and use it in GitHub Desktop.
Python Tutorials - While loop: find the largest number from a large set of entered data
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
# Choose a low number and make it the current max number | |
max = -99999999 | |
# get the first value from user | |
number = int(input("Enter value or -1 to stop: ")) | |
# if the number is not equal to -1, execute the following loop | |
while number != 1: | |
if number > max: # if the number entered is greater than the current max number, | |
max = number # store this number as the max number | |
number = int(input("Enter value or -1 to stop: ")) # keep asking for input until user inputs -1 to quit | |
print("The largest number from the numbers you entered is:", max) # Prints the maximum number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment