simple math Addition test ans score. Random numbers. Enjoy.
from math import * from random import * from kandinsky import * from ion import * from time import * correct=0 wrong=0 questions=choice([10,14,20]) amount=questions gameover=False bg=(randint(200,255),randint(200,255),randint(200,255)) rand_num_1=randint(0,99) rand_num_2=randint(0,99) c=100 d=100 timer=7*10**2 draw_string("Correct: "+str(correct),0,0,"black") draw_string("Wrong: "+str(wrong),150,0,"red") fill_rect(0,0,322,222,bg) while not gameover: fill_rect(0,24,322,2,"black") draw_string("Correct: "+str(correct),0,0,"black",bg) draw_string("Wrong: "+str(wrong),175,0,"red",bg) timer -= 1 ans=str(rand_num_1 + rand_num_2) draw_string(str(rand_num_1)+" + "+str(rand_num_2)+" = "+"?",c,d,"black",bg) if keydown(KEY_OK): rand_num_1=randint(1,200) rand_num_2=randint(1,200) fill_rect(0,100,322,20,bg) timer=10**3 sleep(.3) myans=[] if timer<1 or keydown(KEY_BACKSPACE): timer=7*10**2 rand_num_1=randint(1,25) rand_num_2=randint(1,25) w=input("\n\n\n\n\n\nAnswer? ") if w==ans: draw_string("Correct: "+str(correct),0,0,"black") draw_string("Wrong: "+str(wrong),150,0,"red") fill_rect(0,0,322,222,(randint(200,255),randint(200,255),randint(200,255))) sleep(.1) correct+=1 else: draw_string("Correct: "+str(correct),0,0,"black") draw_string("Wrong: "+str(wrong),150,0,"red") fill_rect(0,0,322,222,(randint(200,255),randint(200,255),randint(200,255))) questions-=1 sleep(.1) wrong+=1 rand_num_1=randint(0,50) rand_num_2=randint(0,50) sleep(.3) if questions<1: draw_string("Correct: "+str(correct),0,0,"black") draw_string("Wrong: "+str(wrong),150,0,"red") sleep(.1) gameover=True fill_rect(0,0,322,222,"black") draw_string("GAME OVER",100,10,"gray","black") draw_string("Correct: "+str(correct),20,80,(randint(50,255),randint(50,255),randint(50,255)),"black") draw_string("Out of : "+str(amount),20,100,"red","black") draw_string("Scored: "+str(correct*10),20,120,"white","black") if correct<round(questions/2): draw_string("study more.",20,180,"magenta","black")