Skip to content

Instantly share code, notes, and snippets.

@Martin-Alexander
Last active June 16, 2016 19:49
Show Gist options
  • Save Martin-Alexander/63565455cde67713b836757e70a0e8bd to your computer and use it in GitHub Desktop.
Save Martin-Alexander/63565455cde67713b836757e70a0e8bd to your computer and use it in GitHub Desktop.
Math quiz
import random
g = random.randrange(-10, 11, 1)
f = random.randrange(-10, 11, 1)
a = []
for i in range(0,10):
try:
x = int(input(" %d" %g + " + " + "%d = " %f))
except:
pass
if g + f == x:
print(" Correct")
a.append(1)
else:
print(" Incorrect")
a.append(0)
g = random.randrange(-10, 11, 1)
f = random.randrange(-10, 11, 1)
print("\n", "Total Score: ",(sum(a)/10)*100, "%")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment