-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGuess_the_number.py
More file actions
31 lines (29 loc) · 1.11 KB
/
Guess_the_number.py
File metadata and controls
31 lines (29 loc) · 1.11 KB
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
from random import randint
print("Welcome to Guessing the Number game...")
print("I'm thinking of a number between 1 to 100...")
chances = 0
if chances == 0 :
d_level = input("\nSelect the difficulty level (easy/medium/hard) : ").lower()
if str(d_level) == "easy":
chances += 10
print("You will get 10 chances to guess the number..")
if str(d_level) == "medium" :
chances += 7
print("You will get 7 chances to guess the number..")
if str(d_level) == "hard":
chances += 5
print("You will get 5 chances to guess the number..")
number = randint(1,100)
while chances >= 0:
answer = int(input("\nMake a guess :"))
if chances == 0 :
print("Oops your chances over....Game over!!")
chances=-1
if answer > 100 or answer < 1:
print("Guess the number between 1 to 100..")
elif answer > number: print("Guess a smaller number..")
elif answer < number : print("Guess a larger number..")
elif answer == number :
print("Correct answer!!...Booyaahhh....")
chances=-1
chances -=1