Created
April 10, 2017 17:38
-
-
Save joetechem/775e0acaaabc2a3aaddb2b0eb64d2685 to your computer and use it in GitHub Desktop.
program chooses from a range of random numbers for the user to guess
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
# Python 2.7 | |
# Code Em Level 2 - Icebreaker | |
# a program to generate random numbers by using the random module | |
# a random number is picked, and the user must guess the number between 1 and 100. | |
import random | |
number = random.randint(1, 100) | |
print("I'm thinking of number between 1 and 100") | |
print("Try to guess the number with as few attempts as possible") | |
print("Here's my hint, try to use a binary search method!") | |
GameRunning = True | |
while True: | |
guess = int(input("Guess a number between 1-100: ")) | |
if guess == number: | |
GameRunning = True | |
print("You guessed correctly!") | |
elif guess > number: | |
print("Your guess was too high") | |
elif guess < number: | |
print("Your guess was too low") | |
else: | |
print("Your did not enter a number") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment