dimanche 21 juin 2015

find time taken by user to solve math problems

I need to write a program that will ask simple random addition problems and find the time it takes the user to solve this. The program should keep on asking math problems until told to stop. It should find the average of correct answers, the fastest answer and the average answer time. I started to write the program but it is not working, so I don't even know how to continue. I cannot get it to print the math problems. can you please show me what I am doing wrong and help me with how to find fastest question and average time per question as well as average for how many questions are correct? here is what the problem should look like when run:

>>> Math()
Are you ready? no
Okay fine
>>> Math()
Are you ready? yes 
0+5=5
4 + 9 = 13
3 + 2 = 89 1+5=6
3+3=9
1+7=8
7 + 7 = 14 5+4=9
1 + 8 = stop
You answered 75% problems correctly
Your average answer time is 1.4388 seconds
Your fastest answer time is 1.2247 seconds

this is what I have:

def fastMath():
ready=input('Are you ready?')
num1 = int(random.randint(0,10))
num2 = int(random.randint(0,10))
operator = '+'
math = ((num1)+ operator +(num2))
if ready == 'no':
    print ('Okay fine')
else:
    start=time.clock
    print (math)
    while math = true:
        print (math)




Aucun commentaire:

Enregistrer un commentaire