Advertisement
Guest User

Untitled

a guest
May 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. TRIALS = 3
  5. PRIZE, EMPTY = True, False
  6. ANSWER = 'введите номер двери от 1 до 3 : '
  7. MESSAGE_OPEN = 'мы открыли {} дверь, за ней ничего нет. Сделаете новый выбор или останетесь на своем?'
  8. SELECT = [(2, 3), (1, 3), (1, 2)]
  9.  
  10. win = 0
  11. doors = [PRIZE, EMPTY, EMPTY]
  12. for _ in range(TRIALS):
  13. random.shuffle(doors)
  14.  
  15. choice = int(input(ANSWER))
  16. declension = ['первую', 'вторую', 'третью']
  17. unselected = SELECT[choice - 1]
  18. if doors[unselected[0] - 1] is PRIZE:
  19. message = MESSAGE_OPEN.format(declension[unselected[0] - 1])
  20. else:
  21. message = MESSAGE_OPEN.format(declension[unselected[1] - 1])
  22. print(message)
  23.  
  24. choice = int(input('второй вопрос')) # второй вопрос?
  25. if choice in doors and doors[choice] is PRIZE: # выбранная дверь and дверь is True:
  26. result = 'победа'
  27. win += 1
  28. else:
  29. result = 'проиграл'
  30. print(result)
  31.  
  32. ratio = (win/TRIALS) * 100
  33. print(f'процент побед: {ratio}%')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement