I'm a beginner in a computer science 1 class. We're learning to code with python. I've been asked to develop code for a simple math quiz. However, my code will no run and I receive the RESTART but no further output. Please advise.
import random
def add(num1, num2):
total_correct = 0
for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "+", num2, '=', end = "")
answer = int(input())
if answer == (num1 + num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct
def sub(num1, num2):
total_correct = 0
for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "-", num2, "=", end = "")
answer = int(input())
if answer == (num1 - num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct
def mult(num1, num2):
total_correct = 0
for I in range(2):
num1 = random.randint(1, 20)
num2 = random.randint(1,20)
print(num1, "*", num2, "=", end = "")
answer = int(input())
if answer == (num1*num2):
print("correct")
else:
print("incorrect")
return total_correct
def div(num1, num2):
total_correct = 0
for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "//", num2, "=", end = "")
answer = int(input())
if answer == (num1//num2):
print("correct")
total_correct+=1
else:
print("incorrect")
return total_correct
def mod(num1,num2):
total_correct = 0
for I in range(2):
num1 = random.randint(1,20)
num2 = random.randint(1,20)
print(num1, "%", num2, "=", end = "")
answer = int(input())
if answer == (num1%num2):
print("correct")
else:
print("incorrect")
return total_correct
again = input()
while again == "yes":
correct_answers=0
correct_answers += add() + sub() + mult() + div() + mod()
print("You've completed the quiz, with a score of", correct_answers, "would you like to try again?", "Type yes to take the quiz again")
again = input()