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
score = 0
for question_number in range(5):
first_number = random.randint(1, 10)
second_number = random.randint(1, 10)
user_answer = int(input(f"What is {first_number} + {second_number}? "))
if user_answer == first_number + second_number:
score += 1
print("You scored", score, "out of 5")