Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
Rock Paper Scissors

Rock, Paper, Scissors Game with Python Free Code

Posted on December 19, 2024December 19, 2024 By Updategadh No Comments on Rock, Paper, Scissors Game with Python Free Code

Game with Python

The Ultimate Rock-Paper-Scissors Game with Money Tracking: Build, Play, and Enjoy!

Are you ready to take the classic game of Rock-Paper-Scissors to the next level? In this blog post, we’ll dive into a fun and engaging way to code this timeless game using Python. Not only will you enjoy the thrill of playing against the computer, but you’ll also keep track of money as the stakes rise! Let’s explore how you can build a fully functional and optimized Rock-Paper-Scissors game.


What Makes This Game Special?

This isn’t your ordinary Rock-Paper-Scissors game. Here’s what makes it unique:

  1. Dynamic Money Tracking: Both the player and the computer start with a set amount of money. Winning or losing a round directly affects your total balance.
  2. Game Over Conditions: The game ends when either the player or the computer runs out of money.
  3. Play Again and Restart Options: You can continue playing multiple rounds or restart the game with new settings.
  4. Optimized Code: The game logic is clean, efficient, and user-friendly.

Now, let’s break down how the game works and the steps to build it.


How the Game Works

  1. Initial Setup:
    • The computer starts with a fixed amount of money (e.g., $40).
    • The player enters their starting amount.
  2. Gameplay:
    • The player chooses one of the three options: Rock, Paper, or Scissors.
    • The computer randomly selects its choice.
    • The winner of the round is decided based on traditional Rock-Paper-Scissors rules.
  3. Money Management:
    • The winner of the round gains $10, while the loser loses $10.
    • Updated balances are displayed after each round.
  4. Game Termination:
    • The game ends when either the player or the computer runs out of money.
    • Players have the option to restart the game or exit.

Game with Python
Game with Python

Code Walkthrough

Here’s the Python code for the game:

import random

# Initial money for the computer
comp_money = 40

while True:
    # Get player's starting amount
    try:
        player_money = int(input("Enter your starting amount: "))
        if player_money <= 0:
            print("Please enter a valid amount greater than 0.")
            continue
    except ValueError:
        print("Invalid input. Please enter a numeric value.")
        continue

    # Game loop
    while True:
        # Choices
        choices = ["rock", "paper", "scissor"]
        comp_choice = random.choice(choices)
        player_choice = None

        # Validate player input
        while player_choice not in choices:
            player_choice = input("Choose rock, paper, or scissor: ").lower()

        print(f"Player: {player_choice}")
        print(f"Computer: {comp_choice}")

        # Determine the winner
        if player_choice == comp_choice:
            print("It's a Tie!")
        elif (player_choice == "rock" and comp_choice == "scissor") or \
             (player_choice == "paper" and comp_choice == "rock") or \
             (player_choice == "scissor" and comp_choice == "paper"):
            print("You Win!")
            player_money += 10
            comp_money -= 10
        else:
            print("Computer Wins!")
            player_money -= 10
            comp_money += 10

        # Display updated amounts
        print(f"Your Total Amount: ${player_money}")
        print(f"Computer's Total Amount: ${comp_money}")

        # Check if anyone is out of money
        if player_money <= 0:
            print("You're out of money! Game over.")
            break
        elif comp_money <= 0:
            print("Computer is out of money! You win the game.")
            break

        # Play again prompt
        play_again = input("Do you want to play again? (Yes/No): ").lower()
        if play_again != "yes":
            break

    # Check if the player wants to restart the game
    restart = input("Do you want to restart the game with a new amount? (Yes/No): ").lower()
    if restart != "yes":
        break

print("Bye! Thanks for playing!")

Key Features in the Code

  1. Input Validation:
    • Ensures the player enters a valid numeric amount for their starting balance.
    • Validates the player’s choice (“rock”, “paper”, or “scissor”).
  2. Dynamic Updates:
    • Tracks the total money for both the player and the computer.
    • Displays updated balances after each round.
  3. Winner Logic:
    • Cleanly determines the winner using concise logical conditions.
  4. Exit and Restart Options:
    • Allows the player to restart with new settings or exit the game gracefully.

Try It Yourself!

To play this game, all you need is Python installed on your computer. Copy the code, paste it into a Python file (e.g., rock_paper_game.py), and run it. Start with a small amount of money and see if you can outsmart the computer!


  • PHP PROJECT:- CLICK HERE
  • Python Projects :-Click Here

rock paper scissors python code copy and paste
rock paper scissors game in python with gui
rock, paper scissors game in python using function
rock paper scissors game in python tkinter
rock paper scissors game python project report
rock, paper scissors python project pdf
rock, paper scissors python with score
rock-paper-scissors game in python github
rock paper scissors python with score

Post Views: 487
Python Tags:rock paper scissors game in python with gui, rock paper scissors python code copy and paste

Post navigation

Previous Post: Database Connection To Python Applications
Next Post: Bakery Shop Chatbot in Python with Free Source Code

More Related Articles

PySpark MLlib: Empowering Machine Learning with Big Data - PySpark MLlib PySpark MLlib: Empowering Machine Learning with Big Data Python
Python Tkinter Frame Widget Python Tkinter Frame Widget Python
How to Install Django How to Install Django: Step-by-Step Guide Python

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. News Portal Project in PHP and MySql Free Source Code
  5. Flipkart Clone using PHP And MYSQL Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme