Lesson 5: Multiplication test with for loop

Post date: Nov 30, 2018 3:54:00 PM

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)