-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject 2.py
More file actions
23 lines (20 loc) · 868 Bytes
/
Copy pathproject 2.py
File metadata and controls
23 lines (20 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#guess the number
import random
def Guess_the_number():
number_to_guess = random.randint(1, 100)
attempts=10
print("welcome to the Guess the number!".title())
print("i have chosen a number between 1 to 100".title())
print(f"you have{attempts} attempts to guess the number".title())
for attempts in range(1,attempts+1):
guess = int(input(f"Attempt{attempts}:enter your guess:".upper()))
if guess<number_to_guess :
print("your guess is to low.")
elif guess>number_to_guess:
print("your guess is to high.")
else:
print(f"congratulations! you have guessed the number in {attempts} attempts".upper())
break
else:
print(f"you used all your attempts.the number was = {number_to_guess}.".upper())
Guess_the_number()