Rock Paper Scissor Game in Python | Console Mini Project for Beginners

Rock Paper Scissor Game Python - Complete Console Project for Beginners

🎮 Rock Paper Scissor Game Python - Complete Console Project

Hey friends! Rock Paper Scissor - classic game everyone knows! Today we create complete version in Python console with computer opponent, score tracking, replay option and input validation. Perfect beginner project to learn game loops, random choices and conditional logic!

Just copy code, run and start beating computer! Works perfectly with unlimited rounds until you quit. No extra libraries needed except Python's built-in random module.

💻 Complete Working Python Code

import random import time def rock_paper_scissor(): # Game choices choices = ["rock", "paper", "scissor"] player_score = 0 computer_score = 0 rounds = 0 print("🎮 Welcome to Rock Paper Scissor Game!") print("Rules: Rock beats Scissor | Scissor beats Paper | Paper beats Rock") while True: rounds += 1 print(f"\n--- Round {rounds} ---") print("\nChoose: 1.rock 2.paper 3.scissor") # Player input with validation while True: player_choice = input("Your choice (1/2/3): ").lower().strip() if player_choice in ["1", "2", "3", "rock", "paper", "scissor"]: if player_choice in ["1", "2", "3"]: player_choice = ["rock", "paper", "scissor"][int(player_choice)-1] break print("❌ Invalid! Enter 1, 2, 3 or full name") # Computer choice computer_choice = random.choice(choices) print(f"\n⏳ Computer thinking...") time.sleep(1) print(f"Your choice: {player_choice.title()}") print(f"Computer: {computer_choice.title()}") # Win conditions if player_choice == computer_choice: print("🤝 It's a DRAW!") elif (player_choice == "rock" and computer_choice == "scissor") or \ (player_choice == "paper" and computer_choice == "rock") or \ (player_choice == "scissor" and computer_choice == "paper"): print("🎉 YOU WIN this round!") player_score += 1 else: print("💻 Computer wins this round!") computer_score += 1 # Show scores print(f"\nScore - You: {player_score} | Computer: {computer_score}") # Replay option while True: play_again = input("\nPlay again? (y/n): ").lower().strip() if play_again in ["y", "yes", "n", "no"]: if play_again in ["n", "no"]: print(f"\n🏆 Final Score - You: {player_score} | Computer: {computer_score}") print("Thanks for playing!") return break print("❌ Enter y/n only!") # Run the game rock_paper_scissor()

✅ Sample Game Output

Round 1: You(rock) vs Computer(scissor) → YOU WIN!

Final Score: You: 3 | Computer: 2

📜 Classic Game Rules

  • Rock ✊ beats Scissor ✌️
  • Scissor ✌️ beats Paper ✋
  • Paper ✋ beats Rock ✊
  • Same choice = Draw 🤝

🧠 How This Code Works?

  • random.choice() - Computer picks randomly
  • while True loops - Unlimited gameplay
  • input validation - Handles wrong inputs
  • score tracking - Counts wins
  • time.sleep() - Dramatic pause
  • conditional logic - Win/draw/lose checks

🔧 Run in 3 Easy Steps

  • Copy complete code to Python editor
  • Save as rock_paper_scissor.py
  • Run with python rock_paper_scissor.py

🎯 Perfect Beginner Features

  • Only 50 lines total code
  • Built-in random + time modules
  • Error-proof input handling
  • Live score display
  • Unlimited replay option
  • Clean console formatting

🚀 Advanced Improvements

  • Add best-of-5 mode
  • Save high scores to file
  • Color output with ANSI codes
  • tkinter GUI version
  • Multiplayer (2 players)
  • Sound effects with pygame

💬 Beat the computer score and share your best score in comments!

Post a Comment

Previous Post Next Post