-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessTheNumber.py
More file actions
52 lines (37 loc) · 873 Bytes
/
guessTheNumber.py
File metadata and controls
52 lines (37 loc) · 873 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#python3
# imports
import random
# vars
min = 1
max = 10
randNum = 0
isGuessing = True
#funcs
def greet():
print("Welcome!\n")
def getRandomNumber(): # assigning a random value to randNum
global randNum
global isGuessing
randNum = random.randint(min, max)
#print(randNum)
def guessPlay(): # actual game-code
global isGuessing
print("Guess the number between ", min, " and ", max, " : ")
playerValue = int(input(""))
if playerValue < randNum:
print("\nToo low... Try again\n")
elif playerValue > randNum:
print("\nToo high... Try again\n")
else:
isGuessing = False
print("\nCongrats! You Won!\n")
#main-loop
def main():
global isGuessing
greet()
getRandomNumber()
while isGuessing:
guessPlay()
#exit()
#calling main func
main()