-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber_Guesser.py
More file actions
32 lines (29 loc) · 963 Bytes
/
Number_Guesser.py
File metadata and controls
32 lines (29 loc) · 963 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
import random
top = int(input("Set a top Margin: "))
random_number = random.randint(0,top)
print("-----------------------------------------")
print("\nGame is to Guess a correct num.")
num = int(input(f"Guess a num from 0 to {top}: "))
count = 0
if num > top:
num = int(input(f"Enter less than {top}: "))
while random_number != num:
if num > top:
num = int(input(f"Enter less than {top}: "))
elif random_number < num:
print("You got wrong...!")
print("Entered num is high!")
num = int(input(f"Guess num less than {num}: "))
print("\n")
else:
print("You got wrong...!")
print("Entered num is low!")
num = int(input(f"Guess num more then {num}: "))
print("\n")
count += 1
if count == 0:
print("You guessed correclty at 1st time")
elif count == 1:
print("You guessed correctly at 2nd time")
else:
print(f"You guessed correctly num after {count+1} trails")