30.7k views
5 votes
Write a Python 3 script in PyCharm that will simulate the game of "Rock, Paper, Scissors": Display a header and the simple rules of RPS Prompt player_1 for their move To make sure player_2 can't see what player_1's move was, insert: print('*** NO CHEATING ***\\\\' * 20) Prompt player_2 for their move Design and develop an IF-ELSE structure to play the game IF player_1's move equivalent to player_2's move, "It's a tie" "rock" beats "scissors" "scissors" beats "paper" "paper" beats "rock" Make sure you test for valid input!!

User SkorKNURE
by
5.9k points

1 Answer

3 votes

Answer:

'''

Rock, Paper, Scissors:

The Rules:

If player1's move equivalent to player2's move, "It's a tie".

"rock" beats "scissors", "scissors" beats "paper", and "paper" beats "rock"

'''

player_1 = input("Player 1's move: ")

print('*** NO CHEATING ***' * 20)

player_2 = input("Player 2's move: ")

if player_1 or player_2 not in ["rock", "paper", "scissors"]:

print("Invalid input!")

if player_1 == player_2:

print("It's a tie")

else:

if player_1 == "rock":

if player_2 == "scissors":

print("Player 1 won")

elif player_2 == "paper":

print("Player 2 won")

elif player_1 == "scissors":

if player_2 == "paper":

print("Player 1 won")

elif player_2 == "rock":

print("Player 2 won")

elif player_1 == "paper":

if player_2 == "rock":

print("Player 1 won")

elif player_2 == "scissors":

print("Player 2 won")

Step-by-step explanation:

In the comment part, put the header and the rules of the game

Ask the user to enter the player1's move

Print the asterisks

Ask the user to enter the player2's move

If any of the input is not "rock", "paper", "scissors", state that the input is invalid

Check the inputs. If they are equal, print that it is a tie. Otherwise:

If player1's move is rock. Check player2's move. If it is "scissors", player1 wins. If it is "paper", player2 wins

If player1's move is scissors. Check player2's move. If it is "paper", player1 wins. If it is "rock", player2 wins

If player1's move is paper. Check player2's move. If it is "rock", player1 wins. If it is "scissors", player2 wins

User Wouter Neuteboom
by
5.7k points