forked from theutpal01/HacktoberFest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numberGuess.py
61 lines (39 loc) · 1.08 KB
/
numberGuess.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
54
55
56
57
58
59
60
61
"""
NUMBER GUESSING GAME - PYTHON
CREATED BY - UTPAL
"""
from random import randint
def checkers(guess, ans):
string = ""
if guess == ans:
string = "You guessed it correct in"
elif abs(ans - guess) <= 50:
if guess > ans:
string = "Little greater than the original answer!"
else:
string = "Little smaller than the original answer!"
elif abs(ans - guess) <= 200:
if guess > ans:
string = "Greater than the original answer!"
else:
string = "Smaller than the original answer!"
elif guess > ans:
string = "Way greater than the original answer!"
elif guess < ans:
string = "Way smaller than the original answer!"
return string
num = randint(randint(1, 200), randint(700, 900))
moves = 10
guess = 0
while moves:
print("You have total moves left =", moves, "\n")
guess = int(input("Make a guess (only numbers): "))
string = checkers(guess, num)
if guess == num:
print(string, 11- moves, "moves!")
break
else:
print(string)
moves -= 1
if guess != num:
print("You have lost the match!\nOut of the moves.\nThe original answer:", num)