-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion_4b.py
More file actions
47 lines (36 loc) · 1.27 KB
/
Copy pathquestion_4b.py
File metadata and controls
47 lines (36 loc) · 1.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# number guessing game
from random import randint
counter = 0
def guess_game():
expected_input = randint(1, 1000)
global counter
counter = 0
player_guess = int(input('Guess a number between 1 to 1000:'))
while player_guess != expected_input:
counter += 1
if player_guess < expected_input:
print('No!!!' + 'Too low, try again\n')
elif player_guess > expected_input:
print('No!!!' + 'Too high, try again\n')
player_guess = int(input('Guess a number between 1 to 1000:'))
else:
print('Right Guess!!!\n')
def score_check():
if counter < 10:
print('You guessed right in less than ten(10) tries, Either you know the secret or you got lucky!\n')
elif counter > 10:
print('You guessed right after more than ten(10) tries, You should be able to do better!\n')
else:
print('You guessed right in exactly ten(10) tries, Aha! You know the secret!\n')
def full_game():
full_guess = 0
while full_guess < 1:
full_guess += 1
guess_game()
score_check()
else:
print('Do you want to play again?')
decision = int(input('Enter 1 to play again or any other key to end: '))
if decision == 1:
full_game()
full_game()