Beginner Python Project: Rock, Paper, Scissors Game

3D icons of a rock, paper, and scissors arranged in a game arena for a Python beginner project.

Following our Number Guessing Game, let’s build another classic: Rock, Paper, Scissors against the computer using Python. This Rock Paper Scissors Python project is a great way to practice coding skills.

This project is great practice for using Lists and Conditional Logic (if/elif/else) to determine a winner.

Step 1: The Setup

We need the random module, and a list of the three possible moves.

import random

choices = ["Rock", "Paper", "Scissors"]

print("=== Rock, Paper, Scissors ===")

Step 2: Get Player & Computer Moves

We’ll use input() for the player and random.choice() for the computer.

# 1. Get Computer Move
computer_move = random.choice(choices)

# 2. Get Player Move
player_move = input("Choose Rock, Paper, or Scissors: ").capitalize()

# Simple validation to make sure they typed it right
if player_move not in choices:
    print("Invalid choice! Game over.")
    exit()

print(f"\nYou chose: {player_move}")
print(f"Computer chose: {computer_move}\n")

Note: .capitalize() helps us by turning “rock” into “Rock” to match our list.

Step 3: Determine the Winner

We need to check all possible win/loss/tie conditions.

if player_move == computer_move:
    print("It's a Tie!")
elif player_move == "Rock":
    if computer_move == "Scissors":
        print("You Win! Rock smashes Scissors.")
    else:
        print("You Lose! Paper covers Rock.")
elif player_move == "Paper":
    if computer_move == "Rock":
        print("You Win! Paper covers Rock.")
    else:
        print("You Lose! Scissors cuts Paper.")
elif player_move == "Scissors":
    if computer_move == "Paper":
        print("You Win! Scissors cuts Paper.")
    else:
        print("You Lose! Rock smashes Scissors.")

Challenge

Wrap this entire game in a while True: loop so the player can keep playing until they type “quit”! You can even add a score counter variable to track wins and losses.

Similar Posts

Leave a Reply