Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
import random
first_factor = random.randint(1, 10)
second_factor = random.randint(1, 10)
product = first_factor * second_factor
while True:
user_guess = int(input("Guess the product (two secret numbers 1-10): "))
if user_guess == product:
print("Correct! It was", first_factor, "x", second_factor)
break
if user_guess < product:
print("Too low")
else:
print("Too high")