1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
def OnContinue():
jouer=input(("Voulez-vous Rejouer? Taper oui pour continuer: "))
return jouer=='oui'
def PoseQuestion(a,b,c):
if c==0:
print (a,"+",b)
if c==1:
print (a,"x",b)
if c==2:
print (a,"-",b)
def TesteReponse(a,b,c,score):
d=int(input("Entrez votre réponse : "))
if c==0:
if d==a+b:
print ("Succes")
score=score+1
return score
else:
print("Echec")
print("La bonne réponse est: ", a+b)
if c==1:
if d==a*b:
print ("Succes")
else:
print("Echec")
print("La bonne réponse est: ", a*b)
if c==2:
if d==a-b:
print ("Succes")
else:
print("Echec")
print("La bonne réponse est: ", a-b)
def Jeu():
a=random.randint(0,99)
b=random.randint(0,99)
c=random.randint(0,2)
PoseQuestion(a,b,c)
TesteReponse(a,b,c,score)
score=0
while True:
Jeu()
if not OnContinue():
break
print("Fin du jeu")
print("Votre score est : ",score) |
Partager