Задание Напишите игру Rock, paper, scissors, lizard, Spock, основываясь на коде, приведенном в уроке.
Дополнительно выполните такие задания:
1. Реализуйте программу таким образом, чтобы пользователь мог повторить игру столько раз, сколько захочет.
Выведите сообщение типа Try again? и варианты ответа:
Yes ([y]) и No ([n]).
2. По завершению игры выведите общий счет и количество побед (Player VS Computer) вот код:
import random
print("")
print("Rock, paper, scissors")
print("Welcome to the game!")
print("The game consists of three rounds.")
print("The winner is the one who scores more points.")
print("\t[r] - rock\n\t[p] - paper\n\t[s] - scissors\n\t[o] - spock\n\t[l] - lizard")
player_score = 0
player_select = 0
comp_score = 0
comp_select = 0
print("")
print("START GAME")
for i in range(3):
print("\tROUND №" + str(i + 1) + "--")
comp_select = random.choice("rps")
while True:
player_select = input("\tYour choice:")
if (player_select == "r") or\
(player_select == "s") or\
(player_select == "l") or\
(player_select == "o") or\
(player_select == "p"):
break
else:
print("\tError")
print("\tComputer:" + comp_select)

if player_select == comp_select:
print("\tDraw!")
elif player_select == "r" and comp_select == "s":
player_score = player_score + 1
print("\You win!")
elif player_select == "r" and comp_select == "p":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "p" and comp_select == "r":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "p" and comp_select == "s":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "s" and comp_select == "p":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "s" and comp_select == "r":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "r" and comp_select == "l":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "s" and comp_select == "o":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "o" and comp_select == "r":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "o" and comp_select == "l":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "l" and comp_select == "o":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "l" and comp_select == "r":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "o" and comp_select == "r":
player_score = player_score + 1
print("\tYou win!")
elif player_select == "r" and comp_select == "o":
comp_score = comp_score + 1
print("\tThe computer wins!")
elif player_select == "p" and comp_select == "l":
comp_score = comp_score + 1
print("\tThe computer wins!")

print("")
print("Game Result")
if player_score > comp_score:
print("Congratulations! You win!")
elif player_score < comp_score:
print("Sorry... The computer wins!")
else:
print("Draw!")
доделайте поже код на питоне

alenka199918 alenka199918    1   03.03.2021 21:39    52

Другие вопросы по теме Другие предметы