-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathnumber_guesser.py
More file actions
38 lines (32 loc) · 881 Bytes
/
Copy pathnumber_guesser.py
File metadata and controls
38 lines (32 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Project: Number Guessing Game
Author: Niveditha T Chandran
Description:
Create a game where the user tries to guess a randomly generated number.
Requirements:
1. Generate a random number between 1 and 100.
2. Ask the user to guess the number.
3. If the guess is too high, display "Too high".
4. If the guess is too low, display "Too low".
5. Continue until the user guesses the correct number.
Sample Output:
Guess the number between 1 and 100
Enter your guess: 50
Too high
Enter your guess: 20
Too low
Enter your guess: 35
Congratulations! You guessed the number.
"""
import random
number=random.randint(1,100)
print("Guess the number between 1 and 100")
while True:
guess=int(input("Enter your guess:"))
if guess>number:
print("Too high")
elif guess<number:
print("Too low")
else:
print("Congratulations! You guessed the number.")
break