From 00ece5bae089b8abe58ad380258a6a5f766d4e8e Mon Sep 17 00:00:00 2001 From: SVNET Libre Date: Thu, 28 Jun 2018 10:51:32 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20score=20:=201=20pts=20/=20bonne=20r?= =?UTF-8?q?=C3=A9ponse=20+=20Optimisation=20diverse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calcul.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/calcul.py b/calcul.py index 78c02c6..99b46f0 100755 --- a/calcul.py +++ b/calcul.py @@ -7,8 +7,12 @@ Created on Wed Jun 27 18:50:20 2018 """ import random +import os +os.system('clear') # On nettoye l'écran +score = 0 while 1: + print("Votre Score est de ", score, " Points\n") # Affichage du score # Tirage au sort des nombres a = random.randint(0,1000) b = random.randint(0,1000) @@ -16,12 +20,16 @@ while 1: # On pose l'opération print("Combien font ", a, " + ", b, " = ") - op = int(input()) + resultat = int(input()) # Vérification - if op == 0: + if resultat == 0: + os.system('clear') print("Au revoir et à Bientôt !!") break - if op == (a+b): + if resultat == (a+b): print("Exact !!\n") + score +=1 # Gagne 1 point + os.system('clear') else: print("Faux !!\nLe Résultat était : ", (a+b), "\n") + os.system('clear')