Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import random
  3. import time
  4.  
  5. endColor = '\033[0m' # закончить цвет
  6. boldText = '\033[01m' # жирный текст
  7.  
  8. options = {"1": "Камень", "2": "Ножницы", "3": "Бумага"}
  9.  
  10. win_u = 0 # победы пользователя
  11. win_c = 0 # победы компьютера
  12.  
  13. while True:
  14.  
  15. time.sleep(0.2)
  16. print(boldText + '\nSCORE:' + endColor)
  17. print(' Вы:', win_u)
  18. print(' Компьютер:', win_c)
  19.  
  20. time.sleep(0.2)
  21. print(boldText + '\n1' + endColor + ' - Камень | ' + boldText + '2' + endColor + ' - Ножницы | ' + boldText + '3' + endColor + ' - Бумага | ' + boldText + 'q ' + endColor + ' - выйти')
  22.  
  23. user = input(boldText + '\n> ' + endColor)
  24. user = user.lower()
  25.  
  26. if user == 'q':
  27. break
  28.  
  29. if user not in options.keys():
  30. print(boldText + '\nВведите число от 1 до 3. \n0 или q - выход' + endColor)
  31. continue
  32.  
  33. choice = random.choice(list(options.keys()))
  34. print('\nВы:', boldText + options[user] + endColor)
  35. print('Рандом:', boldText + options[choice] + endColor)
  36.  
  37. if choice == user:
  38. time.sleep(0.1)
  39. print(boldText + '\nНичья :|' + endColor)
  40. win_u = win_u + 0
  41. win_c = win_c + 0
  42.  
  43. elif (user, choice) in (("1", "2"), ("3", "1"), ("2", "3")):
  44. time.sleep(0.1)
  45. print(boldText + '\nВы выиграли :)' + boldText)
  46. win_u = win_u + 1
  47.  
  48. else:
  49. time.sleep(0.2)
  50. print(boldText + '\nВы проиграли :(' + boldText)
  51. win_c = win_c + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement