# calcul_mental.py

Created by enzo-ginhoux-07

Created on October 11, 2021

3.07 KB

```from random import *

def calculmental():
choix=int(input("Choisir le niveau de 1 à 5"))
if choix == 1:
nb_1=randint(0,100)
nb_2=randint(0,100)
operation=randint(0,1)
if operation==0:
result = nb_1 + nb_2
print(nb_1,"+", nb_2,"=")
print("bonne réponse")
calculmental()
else :
print("la réponse etait :",result)
calculmental()
else:
result = nb_1 - nb_2
print(nb_1, "-", nb_2, "=")
print("bonne réponse")
calculmental()
else :
print("la réponse etait :",result)
calculmental()

elif choix == 2:
nb_1=randint(-100,100)
nb_2=randint(-100,100)
operation=randint(0,1)
if operation==0:
result = nb_1 + nb_2
print(nb_1,"+", nb_2,"=")
print("bonne réponse")
calculmental()
else :
print("la réponse etait :",result)
calculmental()
else:
result = nb_1 - nb_2
print(nb_1, "-", nb_2, "=")
print("bonne réponse")
calculmental()
else :
print("la réponse etait :",result)
calculmental()

elif choix == 3:
nb_1=randint(0,20)
nb_2=randint(0,20)
result = nb_1 * nb_2
print(nb_1, "x", nb_2, "=")
print("bonne réponse")
calculmental()
else:
print("la réponse etait :", result)
calculmental()

elif choix == 4:
r=[2,4]
nb_1 = randint(0, 10)
nb_2 = choice(r)
result = nb_1 / nb_2
print(nb_1, "/", nb_2, "=")
print("bonne réponse")
calculmental()
else:
print("la réponse etait :", result)
calculmental()
else:
print("Ce niveau peut être très difficile")
nb_1 = randint(0, 100)
nb_2 = randint(0, 100)
operation = randint(0, 1)
if operation == 0:
result = nb_1 * nb_2
print(nb_1, "x", nb_2, "=")
print("bonne réponse")
calculmental()
else:
print("la réponse etait :", result)
calculmental()
else:
result = nb_1 * nb_2
print(nb_1, "x", nb_2, "=")