-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.py
More file actions
30 lines (27 loc) · 1.27 KB
/
Game.py
File metadata and controls
30 lines (27 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
# Cisco Python Essentials 1 - Project 1
# Project: Number Guessing Game
import random
# it is used for to import random modules
secret_number=random.randint(1,100)
# use to allow the computer to select one number between 1 to 100
attempt=0
# it will show that how many attempts you made for win or succeed
while True:
# use of while loop to run the program again and again untill we do not
# succeed
user_number=int(input("**** Enter you number **** "))
attempt +=1
# it will ask the user choice and every time will increase 1 try
# untill we do not reach real destination
if user_number==secret_number:
# here conditional statements use
print("**** You have been succeed **** ")
print(f"**** You made {attempt} attempts to win **** ")
break
elif user_number<secret_number:
# if number will be small it will show this message and suggest you for try again
print("Sorry, Your entered number is small Please try again ---> ")
else:
print("Your number is larger than guess number enter small number --->")
# in that case number is larger so it will recommend you for entering small number
print("*** Game Over *** \n ** You are win ** ")