Last active
March 16, 2022 15:59
-
-
Save supcik/e0b833b4e7f01de4cb8fd585fefb64f2 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Programme Python pour faire deviner un nombre | |
Portes ouvertes de la Haute école d'ingénierie | |
et d'architecture de Fribourg | |
""" | |
import random | |
maximum = 100 | |
solution = random.randint(1, maximum) | |
message = "Je viens de penser à un nombre entre 1 et " | |
message += str(maximum) + ". " | |
message += "Essaye de le deviner!" | |
essais = 0 | |
while True: | |
essais += 1 | |
message += " Essai " + str(essais) + " : " | |
choix = input(message) | |
if int(choix) > solution: | |
message = str(choix) + " est trop grand! " | |
elif int(choix) < solution: | |
message = str(choix) +" est trop petit! " | |
else: | |
print("Bravo. Tu as trouvé " + | |
str(solution) + " en " + | |
str(essais) + " essais") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment