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.
import randomdef 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.
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.
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) if input("Play again? (yes/no): ").lower() != "yes":
break- Let's Play!
- Call the play_game function to start your game!
play_game()🎯 Practice Challenges
Master Capstone: Rock Paper Scissors by completing all 3 difficulty levels
Capstone: Rock Paper Scissors - Easy Challenge
Start with the basics. Perfect for beginners!
Capstone: Rock Paper Scissors - Medium Challenge
Get more challenging. Build your confidence!
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!
Keep learning
- ← Previous lessonLesson 17: Number Guessing GameBuild a complete guessing game
- Course overviewAll Python Control Flow lessons18 lessons with practice challenges.
- Grade 7 coursePython Functions & DataPython coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 6 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.