Advertisement
Kaadem-85

juste_prix.py

Dec 30th, 2015
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.72 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: latin-1 -*-
  3.  
  4. from random import randint
  5. from Tkinter import *
  6.  
  7. rejouer = 1
  8.  
  9. while rejouer == True :
  10.  
  11.         nombreAleatoire = randint(0, 100)
  12.  
  13.         print("Choix de la difficulté :")
  14.  
  15.         print("1 - Entre 0 et 100")
  16.  
  17.         print("2 - Entre 0 et 1000")
  18.  
  19.         print("3 - Entre 0 et 10000")
  20.  
  21.         print("4 - Entre 0 et 100000")
  22.  
  23.  
  24.  
  25.         choix_difficulte = input("Quel niveau de difficulté choisis-tu? ")
  26.  
  27.         while choix_difficulte != 1 and choix_difficulte != 2 and choix_difficulte != 3 and choix_difficulte != 4 :
  28.  
  29.             choix_difficulte = input("Entre une valeur correcte s'il te plaît! : ")
  30.  
  31.  
  32.  
  33.         if choix_difficulte == 1 :
  34.  
  35.             nombreAleatoire = randint(0, 100)
  36.  
  37.             print("C'est parti mon kiki!")
  38.  
  39.         elif choix_difficulte == 2 :
  40.  
  41.             nombreAleatoire = randint(0, 1000)
  42.  
  43.             print("C'est parti mon kiki!")  
  44.  
  45.  
  46.  
  47.         elif choix_difficulte == 3 :
  48.  
  49.             nombreAleatoire = randint(0, 10000)
  50.  
  51.             print("C'est parti mon kiki!")
  52.  
  53.  
  54.  
  55.         elif choix_difficulte == 4 :
  56.  
  57.             nombreAleatoire = randint(0, 100000)
  58.  
  59.             print("C'est parti mon kiki!")
  60.  
  61.  
  62.  
  63.         nombre_choisi = input("Le jeu commence... Alors quel nombre as-tu choisi? ")
  64.  
  65.         nombre_choisi = int(nombre_choisi)
  66.  
  67.         i = 0
  68.  
  69.         coups_restants = 10
  70.  
  71.  
  72.  
  73.         while nombre_choisi != nombreAleatoire and i < 10 and coups_restants != 1 :
  74.  
  75.             if nombre_choisi < nombreAleatoire :
  76.  
  77.                 print("C'est plus!")
  78.  
  79.                 coups_restants -= 1
  80.  
  81.                 print("Il te reste " + str(coups_restants) + " coups")  
  82.  
  83.                 nombre_choisi = input("Entre un autre nombre : ")
  84.  
  85.             elif nombre_choisi > nombreAleatoire :
  86.  
  87.                 coups_restants -= 1
  88.  
  89.                 print("C'est moins!")
  90.  
  91.                 print("Il te reste " + str(coups_restants) + " coups")  
  92.  
  93.                 nombre_choisi = input("Entre un autre nombre : ")
  94.  
  95.             i += 1
  96.  
  97.         if nombre_choisi == nombreAleatoire :
  98.  
  99.             print("Bravo! Tu as gagné!")
  100.  
  101.             rejouer = input("souhaites-tu rejouer? Choisis 1 pour \"oui\" et 0 pour \"non\" : ")
  102.  
  103.             while rejouer != 1 and rejouer != 0 :
  104.  
  105.                 rejouer = input("entre une valeur correcte : ")
  106.  
  107.         if coups_restants == 1 :
  108.  
  109.             print("Tu as perdu!")
  110.  
  111.             rejouer = input("souhaites-tu rejouer? Choisis 1 pour \"oui\" et 0 pour \"non\" : ")
  112.  
  113.             while rejouer != 1 and rejouer != 0 :
  114.  
  115.                 rejouer = input("entre une valeur correcte : ")
  116.  
  117. if rejouer == False :
  118.  
  119.         print("Dommage... Au plaisir de te revoir")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement