Last active
December 9, 2025 22:30
-
-
Save GravenilvecTV/956718c478c7880b68fc21e723eb9bda 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 !") |
mamadoumouctarsow
commented
Dec 3, 2025
via email
Ah super !
Bravo !
Le mer. 3 déc. 2025, 16:48, chez-drac ***@***.***> a écrit :
… ***@***.**** commented on this gist.
------------------------------
Bon j'avoue. C'est ici que j'ai pris connaissance du randint mais à part
ça, le reste du code viens de moi et je me suis même permis deux trois trucs
from random import randint
number=randint(1,1000)
player_choice=int(input("entrez un nombre entier : "))
while player_choice!=number :
if player_choice<=number/4 :
print("tu es beaucoup trop bas")
elif number/4<=player_choice<=number/2 :
print("remonte encore")
elif number/2<player_choice<=number-7 :
print("un peu plus haut")
elif number-7<=player_choice<number :
print("tu es juste en dessous")
elif player_choice>=number
*4 :print("tu es beaucoup trop haut")elif number*4>=player_choice>=number
*2 :print("descend encore")elif number*2>=player_choice>=number+7 :
print("un peu plus bas")
elif number+7>=player_choice>=number :
print("tu es juste au dessus")
player_choice=int(input("entrez un nombre entier : "))
continue
if player_choice==number :
print("bravo vous avez gagné")
Screenshot_2025-12-03-16-47-32-510_com.kvassyu.coding.py.png (view on web)
<https://gist.github.com/user-attachments/assets/5bbff904-9bfb-4799-a407-c7857d2eb0f9>
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/GravenilvecTV/956718c478c7880b68fc21e723eb9bda#gistcomment-5890523>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BINGYWN4RP6T53A27P4NQFD374H6BBFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLKJSGQ2TMNZYGM2DJJDOMFWWLKDBMN2G64S7NFSIFJLWMFWHKZNEORZHKZNENZQW2ZN3ORUHEZLBMRPXAYLSORUWG2LQMFXHIX3BMN2GS5TJOR4YFJLWMFWHKZNEM5UXG5FENZQW2ZNLORUHEZLBMRPXI6LQMWWHG5LCNJSWG5C7OR4XAZNLI5UXG5CDN5WW2ZLOOSTHI33QNFRXHEMCUR2HS4DFURTWS43UUV3GC3DVMWUDSMZSGA2TCNJYU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
