I am learning how to use random and math functions but I never really understood loops. so lets say I need a loop that will ask random math problems until told to stop. For something simple like addition of numbers from 0 to 9 how do I write a loop that keeps generating problems. this is an example of a how it can look like:
Math()
Are you ready? yes
0 + 5 = 5
4 + 9 = 13
3 + 2 = 89
7 + 7 = 14
5 + 4 = 9
1 + 8 = stop
so far I have this but I don't know how to make a loop:
def Math():
ready=input('Are you ready?')
num1 = int(random.randint(0,10))
num2 = int(random.randint(0,10))
if ready = 'yes':
while result != 'stop':
num1+'+'+num2 = result
I honestly have no idea how to make a while loop. please help me. Thank you
Aucun commentaire:
Enregistrer un commentaire