SHARE
TWEET

Guess game

katkid May 18th, 2019 177 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. def testrandom():
  5.     flag = 0
  6.     while flag == 0:
  7.         numbers = int(random.random() * 1000)
  8.         if 100 < numbers and numbers < 300:
  9.             flag = 1
  10.             return numbers
  11.  
  12.  
  13. def gameshow(SOLANCHIENTHANG = 0, SOLANDOANCUABAN = 0):
  14.     number = testrandom()
  15.     print("number = ", number)
  16.  
  17.     choose = True
  18.     solandoan = 0
  19.     for i in range(1, 5):
  20.         doanso = int(input("nhap so ban doan: "))
  21.         SOLANDOANCUABAN = SOLANDOANCUABAN + 1
  22.         if doanso == number:
  23.             SOLANCHIENTHANG = SOLANCHIENTHANG + 1
  24.             print("CHUC MUNG BAN DA DOAN DUNG! SO DO LA ", number)
  25.  
  26.             while choose:
  27.                 print(doanso, number, SOLANCHIENTHANG)
  28.                 playagain = input("Ban co muon choi tiep (YES/NO)")
  29.                 if playagain.upper() == 'YES':
  30.                     gameshow(SOLANCHIENTHANG, SOLANDOANCUABAN)
  31.                     choose = False
  32.                 elif playagain.upper() == 'NO':
  33.                     print("Ban da doan chinh xac %s lan, trong %s lan" % (SOLANCHIENTHANG, SOLANDOANCUABAN))
  34.                     choose = False
  35.             break
  36.         else:
  37.             if abs(number - doanso) < 10:
  38.                 print("BAN DOAN GAN DUNG ROI DO")
  39.             else:
  40.                 solandoan = solandoan + 1
  41.                 print("BAN DA DOAN SAI %s LAN" % solandoan)
  42.  
  43.  
  44.     return None
  45.  
  46.  
  47. gameshow()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top