-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise 3.py
More file actions
43 lines (38 loc) · 1.3 KB
/
exercise 3.py
File metadata and controls
43 lines (38 loc) · 1.3 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
######################## GUESS THE NUMBER ##########################
# # Concept:-
# 1. Take input from the user.
# 2. Sujest whelter the number is greater or smaller than the preset number.
# 3. If the user guess is wrong ask user again.
# 4. The user have only 10 chances.
# 5. If user guess the number under his/her 10 chances declare him/her winner
print('\n')
print(" Guess The Number ".center(50, '*'))
print("You Have 10 Chances To Win This Game")
guess = int(input("Enter a number: "))
chances = 9
or_num = 18
game_over = True
while game_over:
if guess<or_num:
print('Try again! Guess greater number than this')
print('\n')
print("You Have",chances,"Chances Left")
guess = int(input("Enter a number again: "))
if chances>1:
chances-=1
else:
print("You loose this game")
break
elif guess>or_num:
print("Try again! Guess smaller number than this")
print('\n')
print("You Have",chances,"Chances Left")
guess = int(input("Enter a number again: "))
if chances>0:
chances-=1
else:
print("Sorry! You loose this game")
break
elif guess==or_num:
print("Congratulation\'s You have won this game by",chances,"chances")
break