forked from Akshay-Vs/Number-Guessing-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_guessing_game.py
53 lines (40 loc) · 1.19 KB
/
number_guessing_game.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import random
max_value =int(input('Enter your level : '))
if max_value==0:
print("\n\tLevel zero is not available\n\t\tGame over\n\nError : ")
remaining_attempts=float(1)
remaining_attempts=75%max_value
player_state=bool(False)
bot_state=bool(False)
if max_value<=10:
level="Easy"
elif max_value>10 and max_value<=40:
level="Hard"
else:
level="Impossible"
remaining_attempts=remaining_attempts -15% remaining_attempts
print('Level applied : ',level,"\nYou got ", remaining_attempts," attempts")
number= random.randint(1, max_value)
bot_input=random.randint(1,max_value)
for I in range(remaining_attempts):
remaining_attempts=remaining_attempts-1
try:
guess = int(input('\nEnter your guess '))
if bot_input==number:
bot_state=True
if guess > number:
print('Too high')
if guess < number:
print('Too low')
if guess==number:
player_state=True
bonus=float(remaining_attempts+10)
remaining_attempts=remaining_attempts+bonus
print("\n Congratulations,You got ",bonus," bonus points")
break
except ValueError:
print("\nInvalid Input\n")
remaining_attempts=remaining_attempts+1
print("\nGame over")
if remaining_attempts==0:
print("You loose the game\n")