-
-
Save kazbom/b62de0f29d6100701bbc472ee1a3cf62 to your computer and use it in GitHub Desktop.
APPRENDRE LE PYTHON #5 ? LES BOUCLES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # importation du randint | |
| from random import randint | |
| # choisir un nombre aleatoire entre 1 et 1000 | |
| just_price = randint(1, 1000) | |
| # statut du jeu (activé/désactivé) | |
| running = True | |
| # tant que le jeu est en cours d'éxécution | |
| while running: | |
| # demander à l'utilisateur d'entrer un prix dans la console | |
| user_price = int(input("Entrer un prix")) | |
| # si le prix est le meme que le juste prix | |
| if user_price == just_price: | |
| print("Trouvé !") | |
| # fin du jeu | |
| running = False | |
| # si le prix de l'utilisateur est supérieur au prix à trouver | |
| elif user_price > just_price: | |
| print("C'est moins") | |
| # si le prix de l'utilisateur est inférieur au prix à trouver | |
| elif user_price < just_price: | |
| print("C'est plus") | |
| # fin du jeu après la boucle | |
| print("Fin du jeu !") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment