Python program to Make Guess of Random Number

from random import randint
guess_num = randint(1,100)
user_input = 0
trial_period = 1
while guess_num != user_input:
   print("The trial no %d: " % trial_period, end='')
   user_input = int(input())
   if user_input < guess_num:
    print("The input number is less")
   elif user_input > guess_num:
    print("The input number is much")
   else:
    print("Kudos! The right guess...")
   trial_period += 1

 

 

 

Output:

The trial no 1: 200
The input number is much
The trial no 2: 1
The input number is less
The trial no 3: 154
The input number is much
The trial no 4: 25
The input number is less
The trial no 5: 3
The input number is less
The trial no 6: 5
The input number is less
The trial no 7: 8
The input number is less
The trial no 8: 23
The input number is less
The trial no 9: 47
The input number is much
The trial no 10: 35
The input number is less
The trial no 11: 48
The input number is much
The trial no 12:

 

Subscribe For Daily Updates