GuttenberG

task2_2

Nov 27th, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import random
  2. username = input('Введите ваше имя')
  3. gamelist = ['Камень', 'Ножницы', 'Бумага']
  4. userpicklist, aipicklist = [], []
  5. userscore, aiscore,  aipick = 0, 0, 0
  6. for i in range(0,3):
  7.     userpick = 0
  8.     if (aiscore == userscore + 2) or (userscore == aiscore + 2 ): break
  9.     while userpick not in range(1, 4):
  10.         userpick = int(input('1 - Камень, 2 - Ножницы, 3 - Бумага '))
  11.         if userpick not in range(1, 4): print('Неправильный ввод')
  12.     aipick = random.randint(1, 3)
  13.     userpicklist.append(gamelist[userpick - 1])
  14.     aipicklist.append(gamelist[aipick - 1])
  15.     if (userpick == 1 and aipick == 2) or (userpick == 2 and aipick == 3) or (userpick == 3 and aipick == 1):
  16.         userscore += 1
  17.     elif userpick == aipick: pass
  18.     else: aiscore += 1
  19. print('{0} - Компьютер'.format(username))
  20. for i in range(0,len(userpicklist)): print('{0} - {1}'.format(userpicklist[i], aipicklist[i]))
  21. if userscore > aiscore:
  22.     print('Игрок {0} победил'.format(username))
  23. elif userscore == aiscore:
  24.     print('Ничья')
  25. else:
  26.     print('Компьютер победил')
Add Comment
Please, Sign In to add comment