Lesson 8: While loop and multiplication test

posted Dec 8, 2017, 7:56 AM by Attila Lengyel
answer = "good"
while answer == "good":
  answer = input("How are you doing?")

import random
goodanswers = 0
while goodanswers < 10:
  a = random.randint(0,10)
  b = random.randint(0,10)
  print("What is",a,"x", b,"?")
  c = int(input())
  if a * b == c:
    goodanswers += 1
  else:
    goodanswers = 0
    print("The answer is", a*b, "!")
 
  print("You have", goodanswers, "points!")
print("You made! You learned the multiplication table.")
Comments