# Day 57 : Number guessing game in Python

import random

import math

lower = int(input("Enter Lower bound:- "))

upper = int(input("Enter Upper bound:- "))

# generating random number between the lower and upper

x = random.randint(lower, upper)

print("\n\tYou've only ",round(math.log(upper - lower + 1, 2)),

" chances to guess the integer!\n")

# Initializing the number of guesses.

count = 0                              #clcoding.com

# for calculation of minimum number of guesses depends upon range

while count < math.log(upper - lower + 1, 2):

count += 1

# taking guessing number as input

guess = int(input("Guess a number:- "))

# Condition testing

if x == guess:

print("Congratulations you did it in ",count, " try")

break

elif x > guess:

print("You guessed too small!")

elif x < guess:

print("You Guessed too high!")

# shows this output.

if count >= math.log(upper - lower + 1, 2):

print("\nThe number is %d" % x)

print("\tBetter Luck Next time!")

```Enter Lower bound:- 1
Enter Upper bound:- 10

You've only  3  chances to guess the integer!

Guess a number:- 6
Congratulations you did it in  1  try```  