Lesson 7: While loop and testing multiplication skills

posted Nov 19, 2019, 7:59 AM by Attila Lengyel
a = 5
b = 7
c = a * b
print(c)

import random as r
a = r.randint(0,10)
b = r.randint(0,10)
c = a * b
print(a,"*", b, "=", c)

a = r.randint(0,10)
b = r.randint(0,10)
print("What is", a, "*", b, "?")
answer = int(input(":"))
if answer == a * b:
print("Good job!!!")
else:
print("Incorrect! It is", a * b)

lower = 10
upper = 20
i = 0
while i < 10:
print(i)
a = r.randint(lower,upper)
b = r.randint(lower,upper)
print("What is", a, "*", b, "?")
answer = int(input(":"))
if answer == a * b:
print("Good job!")
else:
print("Incorrect! It is", a * b)
i = i + 1
Comments