Lesson 26 of 30

Lesson 26 ? Rock, paper, scissors

Title: Build a classic simple game

Description: Use input, random choice, and conditions to play rock, paper, scissors.

Why it matters for kids: This game teaches decision rules clearly.


1. Player choice

pythonpython
player_choice = input("rock, paper, or scissors? ")
print("You chose:", player_choice)

2. Computer choice

pythonpython
import random

choices = ["rock", "paper", "scissors"]
computer_choice = random.choice(choices)

print("Computer chose:", computer_choice)

3. Tie check

pythonpython
player_choice = "rock"
computer_choice = "rock"

if player_choice == computer_choice:
    print("Tie!")

4. Full simple version

pythonpython
import random

choices = ["rock", "paper", "scissors"]
player_choice = input("rock, paper, or scissors? ").lower()
computer_choice = random.choice(choices)

print("Computer chose:", computer_choice)

if player_choice == computer_choice:
    print("Tie!")
elif player_choice == "rock" and computer_choice == "scissors":
    print("You win!")
elif player_choice == "paper" and computer_choice == "rock":
    print("You win!")
elif player_choice == "scissors" and computer_choice == "paper":
    print("You win!")
else:
    print("Computer wins.")

5. Easy examples

pythonpython
print("rock" == "rock")
print("rock" == "paper")
pythonpython
choice = "ROCK"
print(choice.lower())
pythonpython
winning_pair = "paper beats rock"
print(winning_pair)

6. Mini challenge

Click each example to open it.

Example 1

Ask the player for rock.

Example 2

Ask the player for paper.

Example 3

Ask the player for scissors.

Example 4

Pick a random computer choice.

Example 5

Check if the game is a tie.

Example 6

Check rock beats scissors.

Example 7

Check paper beats rock.

Example 8

Check scissors beats paper.

Example 9

Print computer wins for other cases.

Example 10

Show a message for a wrong choice.