forked from RK1905101/Mini_Python_Projects
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberGuess.py
More file actions
Latest commit
21 lines (17 loc) · 627 Bytes
/
Copy pathNumberGuess.py
File metadata and controls
21 lines (17 loc) · 627 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importrandom
turn=5
guess=0
number=random.randrange(25) +1
print("The computer is thinking of a number between 1 to 25. Try guessing it. You have 5 turns")
whileguess!=numberandturn!=0:
print("Turns Remaining: ", turn)
guess=int(input("Guess a number: "))
ifguess<numberandturn!=1:
print("Guess a greater number.")
elifguess>numberandturn!=1:
print("Guess a lower number.")
turn=turn-1
ifguess==number:
print("Congratulations! You won!")
ifturn==0andguess!=number:
print("Sorry! You ran out of turns. The computer guessed: ", number)