Last active
June 16, 2016 19:49
-
-
Save Martin-Alexander/63565455cde67713b836757e70a0e8bd to your computer and use it in GitHub Desktop.
Math quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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