You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Guessing_Game.py
+1-8Lines changed: 1 addition & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,17 @@
3
3
a=comGuess=randint(0, 100) # a and comGuess is initialised with a random number between 0 and 100
4
4
5
5
whileTrue: # loop will run until encountered with the break statement(user enters the right answer)
6
-
7
6
userGuess=int(input("Enter your guessed no. b/w 0-100:")) # user input for guessing the number
8
7
9
8
ifuserGuess<comGuess: # if number guessed by user is lesser than the random number than the user is told to guess higher and the random number comGuess is changed to a new random number between a and 100
10
9
print("Guess Higher")
11
10
comGuess=randint(a, 100)
12
11
a+=1
13
-
count=1
14
12
15
13
elifuserGuess>comGuess: # if number guessed by user is greater than the random number than the user is told to guess lower and the random number comGuess is changed to a new random number between 0 and a
16
14
print("Guess Lower")
17
15
comGuess=randint(0, a)
18
16
a+=1
19
-
count=1
20
-
21
-
22
-
elifuserGuess==comGuessandcount==0 :#the player needs a special reward for perfect guess in the first try ;-)
23
-
print("Bravo! Legendary Guess!")
24
17
25
-
else:#Well, A Congratulations Message For Guessing Correctly!
18
+
else:#Well, A Congratulations Message For Guessing Correctly!
26
19
print("Congratulations, You Guessed It Correctly!")
0 commit comments