import random
score = 0
ops = ['+','-','*']
num1 = random.randint(1,9)
num2 = random.randint(1,9)
operation = random.choice(ops)
print(num1)
print(operation)
print(num2)
user = int(input(""))
if operation == "+":
answer = num1 + num2
elif operation == "-":
answer = num1 - num2
elif operation == "*":
answer = num1 * num2
if user == answer:
print("correct")
score = score + 1
else:
print("Incorrect")
print (score)
lundi 23 novembre 2015
How would I loop a randomly generated arithmetic 10 times over? this is my code so far
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire