Project - Can you Guess the Number?

 Source Code given below:-


import random

# this programme finds a number based on binary search logic


guessNum = random.randint(0, 100)

print("Try to guess the numbers! : ")

chances = 10

for i in range(1, chances+1):

    num = int(input())


    if num > guessNum:

        if num > guessNum + 10:

            print("Your number is too large!")

        else:

            print("Your number is large.")

    elif num < guessNum:

        if num < guessNum - 10:

            print("your number is too small!")

        else:

            print("your number is small.")

    else:

        print("^-^ ^-^ ^-^ ^-^ ^-^ ^-^\nCongratulations!! You won.\n^-^ ^-^ ^-^ ^-^ ^-^ ^-^")

        break


if i == 10:

    print("**********\nGame Over!\n**********")


Comments