Lesson 5: Multiplication test with for loop

posted Nov 30, 2018, 7:54 AM by Attila Lengyel
print("Let's practice! What is 4 x 9?")
answer = int(input())
print("Your answer is", answer)
if answer == 36:
print("Correct!")
else:
print("Incorrect. Please practice math!")

import random
print("Are you ready for a test?")
for i in range(1,11):
a = random.randint(2,9)
b = random.randint(2,9)
print("Question", i,": What is", a, "x", b, "?")
answer = int(input())
if answer == a * b:
print("Correct!")
else:
print("Incorrect! The answer is", a * b)
Comments