How to Create a Rock, Paper, Scissors Game Using Python

Creating a “Rock, Paper, Scissors” game in Python is a great way to enhance your programming skills. You can create the game with a single Python script, and play it on the command line.

The game starts by asking the player for their choice: “rock”, “paper”, or “scissors”. It then waits for them to enter their response. you could play the game against a “computer” player, which will automatically select its move.

4

The game can also include many rounds. So even if you lose the first round, you can still try to win two out of three!

How to Set Up the Game and Ask the Player for Their Move

When the game starts, the Python program should ask the player to enter either “rock”, “paper”, or “scissors”, and take in the player’s response. To set up a new game, start by creating a new Python file with a .py extension.

The full code for this tutorial is available ina GitHub repository.

Person making a scissors gesture with their hand

How to Take Turns With the Computer and Compare Moves

Once you have entered your move, the computer will take its turn by randomly selecting either “rock”, “paper”, or “scissors”. The game will then have to compare your move with the computer’s move to determine who won.

How to Keep Score Between the Player and the Computer Between Multiple Rounds

You can also add additional rounds, where you and the computer take three turns each.

Once you and the computer have picked either rock, paper, or scissors, the game will ask you again, and keep track of your scores. The score for the player increases based on who won that particular round.

Rock Paper Scissors game intro in the command line

How to Run the Game

To play the game, run the Python script using a terminal or command prompt. Enter your move and wait for the computer to make theirs. Once you have completed three rounds, the program will display the winner.

Learn Python by Creating Games

Creating simple games such as a “Rock, Paper, Scissors” game is a great way to get more familiar with programming concepts. There are so many other fun games you can make using Python, such as a text-based adventure game.

Practice your Python programming with some simple text processing and decision handling to create a playable game.

Rock Paper Scissors gameplay in the command line

Flagship price, mid-range phone.

OneDrive is one of the best, but it has a catch.

Person holding gameboy console

So much time invested, and for what?

Tor spoiled me forever.

Don’t let aging hardware force you into buying expensive upgrades.

Technology Explained

PC & Mobile