import random import time q = 1 w = 0 cor = 0 for x in range (0,10): a = float(random.randint(1, 10)) b = float(random.randint(1, 10)) cc = ['*', '+', '/', '-'] c =(random.choice(cc)) print("Question "+str(q)) g = float(input(str(a)+str(c)+str(b)+" =")) gg = ['weldone', 'keep it up!', 'really good', 'nice!', 'good one', 'keep going!', 'too good'] g =(random.choice(gg)) bb = ['try again!', 'better luck next time', 'good effort', 'close!', 'mabey next time', 'good but not good enough'] b =(random.choice(bb)) if g == str(a)+str(c)+str(b): print("CORRECT "+str(g)) q = q + 1 cor = cor + 1 else: print("WRONG, "+str(b)) q = q + 1 w = w + 1 if q == 11: print ("end of test") print ("you have "+str(cor)+" questions correct, out of 10 questions") print ("you have "+str(w)+" questions wrong, out of 10 questions") print("Your teacher will be notified")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question