Contact Us:

670 Lafayette Ave, Brooklyn,
NY 11216

+1 800 966 4564
+1 800 9667 4558

Rock Paper Scissors

Instructions

Make a rock, paper, scissors game.

Inside the main.py file, you’ll find the ASCII art for the hand signals already saved to a corresponding variable: rockpaper, and scissors. This will make it easy to print them out to the console.

Start the game by asking the player:

“What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.”

From there you will need to figure out:

  • How you will store the user’s input.
  • How you will generate a random choice for the computer.
  • How you will compare the user’s and the computer’s choice to determine the winner (or a draw).
  • And also how you will give feedback to the player.

You can find the “official” rules of the game on the World Rock Paper Scissors Association website.

import random
def myList():
  # Rock
  rock = """
      _______
  ---'   ____)
        (_____)
        (_____)
        (____)
  ---.__(___)
  """
  # Paper
  paper = """
      _______
  ---'    ____)____
            ______)
            _______)
          _______)
  ---.__________)
  """
  # Scissors
  scissors = """
      _______
  ---'   ____)____
            ______)
        __________)
        (____)
  ---.__(___)
  """
  gameImages = [rock, paper, scissors]
  askPlayer = int(input("What do you choose?\nType...\n0 for Rock\n1 for Paper\n2 for Scissors\n"))
  if askPlayer > 2:
    print("Invalid Operaion!")
  else:
    print(gameImages[askPlayer])
    randomNum = random.randint(0, 2)
    print(gameImages[randomNum])
    if askPlayer > randomNum:
      print("You won!")
    elif randomNum > askPlayer:
      print("You lose!")
    elif askPlayer == randomNum:
      print("Game Draw!")
  print("\nwant to play again?")
while True:
  myList()
0 0 votes
Article Rating

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x