TalentJR

Lesson 18

Capstone: Rock Paper Scissors

Combine everything into a full game

1What Is The Game?✨

Rock Paper Scissors is a classic hand game where two players choose one of three options: rock, paper, or scissors. The rules are simple: rock crushes scissors, scissors cuts paper, and paper covers rock. In this capstone project, you will create a Python program that allows a player to compete against the computer!

2Why Build This Game?🎯

  • ✓ Practice using conditional statements
  • ✓ Utilize loops for repeated play
  • ✓ Implement random choices for the computer
  • ✓ Build a fun, interactive game

3Setting Up The Game💡

First, we need to import the random module so we can let the computer make random choices. Then, we will define a function to get the player's choice.

💻 code
import random
💻 code
def get_player_choice():
    choice = input("Choose rock, paper, or scissors: ")
    return choice.lower()

4Creating The Game Logic🚀

Next, we will create a function that compares the player's choice to the computer's choice and determines the winner.

💻 code
def determine_winner(player, computer):
    if player == computer:
        return "It's a tie!"
    elif (player == "rock" and computer == "scissors") or (player == "scissors" and computer == "paper") or (player == "paper" and computer == "rock"):
        return "You win!"
    else:
        return "Computer wins!"

5Putting It All Together🔍

Now, we'll combine everything into a loop so players can play multiple rounds until they choose to quit.

💻 code
def play_game():
    while True:
        player_choice = get_player_choice()
        computer_choice = random.choice(["rock", "paper", "scissors"])
        print(f"Computer chose: {computer_choice}")
        result = determine_winner(player_choice, computer_choice)
        print(result)
💻 code
        if input("Play again? (yes/no): ").lower() != "yes":
            break
  • Let's Play!
  • Call the play_game function to start your game!
💻 code
play_game()

🎯 Practice Challenges

Master Capstone: Rock Paper Scissors by completing all 3 difficulty levels

🟢 EASY

Capstone: Rock Paper Scissors - Easy Challenge

Start with the basics. Perfect for beginners!

🟡 MEDIUM

Capstone: Rock Paper Scissors - Medium Challenge

Get more challenging. Build your confidence!

🔴 HARD

Capstone: Rock Paper Scissors - Hard Challenge

Master this concept. Prove your skills!

🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →

Ready to Master Capstone: Rock Paper Scissors? 🚀

Complete the challenges, take the quiz and keep your learning streak going!