-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from rutuja060/main
add guess game
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# THIS IS A GUESS THE NUMBER GAME | ||
import random | ||
|
||
print("Hello, what is your name?") | ||
name=input() | ||
|
||
print("well," +name+ ",i am thinking of a number between 1 to 20.") | ||
secretnumber=random.randint(1,20) | ||
|
||
for guessesTaken in range(1,7): | ||
print("Take a guess") | ||
guess = int(input()) | ||
if guess < secretnumber: | ||
print("Your guess is too low") | ||
elif guess > secretnumber: | ||
print("Your guess is too high") | ||
else: | ||
break | ||
|
||
|
||
if guess == secretnumber: | ||
print("good job,"+name+"!you guessed my number in " +str(guessesTaken)+ " guesses") | ||
else: | ||
print("nope. the number i was thinking of was"+str(secretnumber)) |