gestion des erreurs de saisie texte / nombres
This commit is contained in:
86
calcul.py
86
calcul.py
@@ -31,16 +31,21 @@ while tour <= 10:
|
|||||||
os.system('clear')
|
os.system('clear')
|
||||||
print(u"Au revoir et à Bientôt !!")
|
print(u"Au revoir et à Bientôt !!")
|
||||||
break
|
break
|
||||||
if int(resultat) == (a+b):
|
try:
|
||||||
print(u"Exact !!\n")
|
if int(resultat) == (a+b):
|
||||||
score +=1 # Gagne 1 point
|
print(u"Exact !!\n")
|
||||||
|
score +=1 # Gagne 1 point
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
else:
|
||||||
|
print(u"Faux !!\nLe Résultat était : ", (a+b), "\n")
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
except ValueError:
|
||||||
|
print("C'est des maths et non pas de la littérature !!")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
else:
|
|
||||||
print(u"Faux !!\nLe Résultat était : ", (a+b), "\n")
|
|
||||||
time.sleep(2)
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
if op == 2:
|
if op == 2:
|
||||||
print("Combien font ", a, " - ", b, " = ")
|
print("Combien font ", a, " - ", b, " = ")
|
||||||
resultat = input()
|
resultat = input()
|
||||||
@@ -48,16 +53,21 @@ while tour <= 10:
|
|||||||
os.system('clear')
|
os.system('clear')
|
||||||
print(u"Au revoir et à Bientôt !!")
|
print(u"Au revoir et à Bientôt !!")
|
||||||
break
|
break
|
||||||
if int(resultat) == (a-b):
|
try:
|
||||||
print(u"Exact !!\n")
|
if int(resultat) == (a-b):
|
||||||
score +=1 # Gagne 1 point
|
print(u"Exact !!\n")
|
||||||
|
score +=1 # Gagne 1 point
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
else:
|
||||||
|
print(u"Faux !!\nLe Résultat était : ", (a-b), "\n")
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
except ValueError:
|
||||||
|
print("C'est des maths et non pas de la littérature !!")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
else:
|
|
||||||
print(u"Faux !!\nLe Résultat était : ", (a-b), "\n")
|
|
||||||
time.sleep(2)
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
if op == 3:
|
if op == 3:
|
||||||
print("Combien font ", a, " X ", b, " = ")
|
print("Combien font ", a, " X ", b, " = ")
|
||||||
resultat = input()
|
resultat = input()
|
||||||
@@ -65,16 +75,21 @@ while tour <= 10:
|
|||||||
os.system('clear')
|
os.system('clear')
|
||||||
print(u"Au revoir et à Bientôt !!")
|
print(u"Au revoir et à Bientôt !!")
|
||||||
break
|
break
|
||||||
if int(resultat) == (a*b):
|
try:
|
||||||
print(u"Exact !!\n")
|
if int(resultat) == (a*b):
|
||||||
score +=1 # Gagne 1 point
|
print(u"Exact !!\n")
|
||||||
|
score +=1 # Gagne 1 point
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
else:
|
||||||
|
print(u"Faux !!\nLe Résultat était : ", (a*b), "\n")
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
except ValueError:
|
||||||
|
print("C'est des maths et non pas de la littérature !!")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
else:
|
|
||||||
print(u"Faux !!\nLe Résultat était : ", (a*b), "\n")
|
|
||||||
time.sleep(2)
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
if op == 4:
|
if op == 4:
|
||||||
print("Combien font ", a, " / ", b, " = (donnez l'entier)")
|
print("Combien font ", a, " / ", b, " = (donnez l'entier)")
|
||||||
resultat = input()
|
resultat = input()
|
||||||
@@ -82,16 +97,21 @@ while tour <= 10:
|
|||||||
os.system('clear')
|
os.system('clear')
|
||||||
print(u"Au revoir et à Bientôt !!")
|
print(u"Au revoir et à Bientôt !!")
|
||||||
break
|
break
|
||||||
if int(resultat) == int(a/b):
|
try:
|
||||||
print(u"Exact !!\n")
|
if int(resultat) == int(a/b):
|
||||||
score +=1 # Gagne 1 point
|
print(u"Exact !!\n")
|
||||||
|
score +=1 # Gagne 1 point
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
else:
|
||||||
|
print(u"Faux !!\nLe Résultat était : ", (a/b), "\n")
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('clear')
|
||||||
|
except ValueError:
|
||||||
|
print("C'est des maths et non pas de la littérature !!")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
else:
|
|
||||||
print(u"Faux !!\nLe Résultat était : ", (a/b), "\n")
|
|
||||||
time.sleep(2)
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
tour += 1
|
tour += 1 #Incrément tour
|
||||||
|
|
||||||
print("Partie terminée, vous avez marqué ", score, "point(s)")
|
print("Partie terminée, vous avez marqué ", score, "point(s)") # Fin de Partie
|
||||||
Reference in New Issue
Block a user