Created
May 12, 2016 18:22
-
-
Save jaronoff97/b01a73f3368f4b0cf0b0575f5c80d184 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
secret_number = 27 | |
lower_bound = 0 | |
upper_bound = 100 | |
their_number = -100 | |
def guessing_game(number): | |
if number <= lower_bound or number >= upper_bound: | |
print("Out of bounds!") | |
return # stops the method, we could also just say return, but break is a really useful control flow statement | |
if number > secret_number: | |
print("TOO HIGH!") | |
elif number < secret_number: | |
print("TOO LOW!") | |
elif number == secret_number: | |
print("You got it! My number was {0}".format(secret_number)) | |
else: | |
print("This should never happen!") | |
while their_number is not secret_number: | |
their_number = input("Guess a number: ") | |
guessing_game(their_number) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment