Advertisement
rezaul525

Number Guessing Game

Feb 17th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. # python module
  2. import time   #for time backend
  3. import random   #for random numbers
  4. # Module End
  5.  
  6. # veriable start
  7.  
  8. t1 = time.time()
  9. winning_number = random.randint(1,100) #Can input any number like(1,50,100, n)
  10. guess = 1
  11. game_over = False
  12.  
  13. # veriable end
  14.  
  15. # input Your Number
  16. number = int(input(' Enter your Number:  '))
  17.  
  18. # While loop and start Your Game
  19. while not game_over:
  20.  
  21.     #Nested if condition
  22.     if number == winning_number:
  23.         print(f'You win, and the gussing number is {guess} times \n Thank You For Playing \U0001F642')
  24.         game_over = True   # Game over
  25.         # t2 is a veriable
  26.         t2 = time.time()
  27.         # t2 end here
  28.         print(f'Your Gaming Process Time(Backend Time): {t2-t1}') #for backend time process
  29.         input('Press Enter to Close ')
  30.        
  31.     else:
  32.         if number < winning_number:
  33.             print('Too low')
  34.         else:
  35.             print('Too high')
  36.         #Nested If condition end
  37.  
  38.         guess += 1
  39.         number = int(input('Guess Again: '))
  40.        
  41.        
  42.        
  43.         # <------------------------------------   Happy Gaming  ------------------------------------------->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement