Guest User

Untitled

a guest
Nov 28th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # Игра позволяет пользователю загадать число от 1 до 100 и компьютер его угадывает
  2. # В конце выводится загаданное число и количество затраченных компьютером попыток
  3.  
  4. import random
  5.  
  6. print("\tWelcome to the game 'Guess The Number'")
  7. print("You think the number and the computer tries to guess this number.\n")
  8.  
  9. number = ""
  10.  
  11. while number not in range(1, 100):
  12.     number = int(input("Enter the number in the range between 1 to 100: "))
  13.  
  14. numbers_list = []
  15. tries = 0
  16.  
  17. while random.randrange(1, 100) != number:
  18.     tries += 1
  19. else:
  20.     print("Your number is", number, ". Total tries is", tries)
Advertisement
Add Comment
Please, Sign In to add comment