Rock Paper Scissors Game using Python
Rock Paper Scissors is a hand game usually played between two people. In this game, scissors can beat paper, paper can beat rock, and rock can beat scissors.
![]() |
Rock Paper Scissors Game |
If you want to learn how to create a Rock Paper Scissors game with Python, this guide is for you.
To create and play Rock Paper Scissors, I will be using if
and elif
statements in Python. The game will be designed to be played between two players. Player-1 will be the user, and Player-2 will be the computer.
- Player-1 will manually select rock, paper, or scissors, while
- Player-2 will choose randomly. For this, I will also use the
random
module in Python.
I hope you now understand everything about the Rock Paper Scissors game and how to create it. Below is how we can write a Python script to create and play Rock Paper Scissors using Python:
import random
def play_game():
choices = ["rock", "paper", "scissors"]
computer_choice = random.choice(choices)
user_choice = input("Enter your choice (rock, paper, or scissors): ").lower()
if user_choice not in choices:
print("Invalid choice! Please choose rock, paper, or scissors.")
return
print(f"Computer chose: {computer_choice}")
if user_choice == computer_choice:
print("It's a tie!")
elif (user_choice == "rock" and computer_choice == "scissors") or \
(user_choice == "scissors" and computer_choice == "paper") or \
(user_choice == "paper" and computer_choice == "rock"):
print("You win!")
else:
print("You lose!")
play_game()
So this is how you can easily create and play Rock Paper Scissors using the Python programming language as a beginner. If you are new to Python, you should keep working on such programming projects to improve your skills. Have fun coding!