Skip to content

Instantly share code, notes, and snippets.

@Proxdlahess
Forked from GravenilvecTV/main.py
Created December 12, 2024 19:34
Show Gist options
  • Select an option

  • Save Proxdlahess/bdd462f4167beb313f695ef31227718e to your computer and use it in GitHub Desktop.

Select an option

Save Proxdlahess/bdd462f4167beb313f695ef31227718e to your computer and use it in GitHub Desktop.
APPRENDRE LE PYTHON #5 ? LES BOUCLES
# 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 !")
@Proxdlahess
Copy link
Author

Moi perso j'ai fais comme sa :
`Nombre_à_trouver = randint(1, 1000)
kaka = True

print("")
print("")
print("Bienvenue dans le generateur de nombre dla hess !!!")
print("Dans ce jeu vous devrez trouver le bon nombre")
print("")
print("Exemple:")
print(" VOus devez trouver 53, et vous devrez mettre un nombre reflechis au à chaque fois l'ordi va vous dire si c'est plus ou moin.")
print("")
print("Allons commencons !!!")
print("")

while kaka:
question_nombre = int(input("Entrez un nombre"))
if question_nombre == Nombre_à_trouver:
print("Bravo, c'est gagnée !!!")
kaka = False
elif question_nombre > Nombre_à_trouver:
print("C'est moin")

elif question_nombre < Nombre_à_trouver:
    print("C'est plus")

print("C'est la fin bien jouée !!")

    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment