The Guessing Game¶
The goal of this excersise is to build a simple guessing game.
Setup¶
In this game, a random number is picked by the code between 1 and 100.
Win Condition¶
If the user guesses the secret number, the user wins and the game ends.
Lose Condition¶
If the user can't guess the secret number in 10 guesses, the user loses and the game ends.
Hints¶
Each time the user guesses and they're wrong, but still have guesses left, the game gives the user a hint telling them if the secret number is greater or less than their guess.
Provided¶
To start, I've provided you with:
- Code to set up a random
secret_number
varaible. - Code to get the user's
guess_number
. - Code to tell the user if their guess is correct.
In [1]:
Copied!
# Code to set up the secret_number, don't change this
from random import randint
secret_number = randint(1, 100)
# ---------------------------------------------------
# Example Starter Code Below
guess_number = int(input("Enter your guess: "))
if guess_number == secret_number:
print("You win!")
else:
print("You lose!")
# Code to set up the secret_number, don't change this
from random import randint
secret_number = randint(1, 100)
# ---------------------------------------------------
# Example Starter Code Below
guess_number = int(input("Enter your guess: "))
if guess_number == secret_number:
print("You win!")
else:
print("You lose!")
Enter your guess: 70 You lose!
In [ ]:
Copied!