math quiz
import random
print("What is your name?")
name = input().title()
print (name, ", Welcome to this math quiz! ")
score = 0
question = 0
print ("answer the following questions:")
while question < 5:
symbol = random.randint(1,2)
num1 = random.randint(1,25)
num2 = random.randint(1,25)
if symbol == 1:
print("What is", num1, "+", num2)
ans = num1 + num2
elif symbol == 2:
print("What is", num1, "-", num2)
ans = num1 - num2
while True:
try:
user_ans = int(input())
except ValueError:
print ("type using numbers.")
continue
else:
break
if user_ans == ans:
print("Correct Answer")
score += 1
else:
print("Wrong Answer")
question += 1
print ("you scored", score, "/5")
print("You have scored", score100/5, "%")
if score100/5 >= 50 :
print(name, " you have passed the quiz")
else:
print(name,",you have failed the quiz.")
Pretty easy
I could make this