# this is a small guessing game for users to guess a number between 0 to 100. # the count will tell the users how many tries he/she got until he/she got the right number. # if the difference between the guess and answer is more or equal to 10, # it will print too low or too high # if it's less, then it will print close but try again # this will choose a random number from 0 to 100 import random x = random.randint(0,100) count = 0 while True: y = int(input("Enter a number between 1 and 100: ")) # this is the same notation as count = count + 1 count += 1 if x != y: if x-y >= 10: print("Too low.") elif x-y <= -10: print("Too high.") elif 0 < x-y <= 10: print("Close, but not quite. Guess a bit higher.") elif 0> x-y >= -10: print("Close, but not quite. Guess a bit lower.") else: break print("Correct number. You've guessed", count, "number of times.")