Python

Rock, paper, scissor game using python

Python is a multi-purpose language which can be used to do anything. You can also develop games using python. In this python project, we are going to develop a Rock, paper, scissor game using python. Rock, paper, scissor is a game which is played between two individuals. Here you are going to develop a game where your opponent is the computer. We are not going to use any external library to develop this game.

Read more..


Project Implementation:

First, import the randint() from the random module.

randint() - It is a function which generates random integers from the given range.

from random import randint

Now, we will create the play options. Rock, Paper, scissor are the play options that you and the computer make on each turn.

t = [“Rock, “Paper”, “Scissor”]

Setup the players (computer and you)

Let’s assign a random play to the computer with the help of randint function, list and t

computer = t[randint(0,2)]

Set the player to False

player = False

Let’s write the actual program where we will create the scenes for all the probabilities such as rock-paper, paper-scissor, scissor-rock, and vice versa for all the three probabilities.

Now, we will look into the while loop. While loop is used in a programming language which allows the code to be executed continuously based on the given condition.

while player == False:

When the loop starts the computer waits for your turn to play. When you start playing, your status changes from False to True. Since the value is assigned to the variable makes the player True.

player = input(“Rock, Paper, Scissor?”)

if player == computer:

print("Tie!")

If the player input and the computer input are the same, the output is a tie.


Latest projects on Python

Want to develop practical skills on Python? Checkout our latest projects and start learning for free


elif player == "Rock":

if computer == "Paper":

If the player input is “rock” and computer’s input is “Paper”, the output will be the following

print("You lose!", computer, "covers", player)

else:

            print("You win!", player, "smashes", computer)

Otherwise, it will display the above line.

elif player == "Paper":

        if computer == "Scissors":

            print("You lose!", computer, "cut", player)

        else:

            print("You win!", player, "covers", computer)

If the player chooses paper and computer choose scissor it will display player as looser and computer as the winner. Else it will print player as winner and computer as loose.

elif player == "Scissors":

        if computer == "Rock":

            print("You lose...", computer, "smashes", player)

        else:

            print("You win!", player, "cut", computer)

Here the player input is scissor and the computer input is rock so the result is lost for the player and win for the computer.

If the input is opposite it will reverse the results.

else:

        print("That's not a valid play. Check your spelling!")

If the given input is not there in the list means it will print the above.

player = False

    computer = t[randint(0,2)]

Player was set into False to continue with the loop.

The code for the Rock, paper, scissor, python game is finished. You can compile the code using the python interpreter. Let me know your thoughts about this project in the comment section.


How to build Python projects Did you know

Skyfi Labs helps students learn practical skills by building real-world projects.

You can enrol with friends and receive kits at your doorstep

You can learn from experts, build working projects, showcase skills to the world and grab the best jobs.
Get started today!


Kit required to develop Rock, paper, scissor game using python:
Technologies you will learn by working on Rock, paper, scissor game using python:
Rock, paper, scissor game using python
Skyfi Labs Last Updated: 2022-04-16





Join 250,000+ students from 36+ countries & develop practical skills by building projects

Get kits shipped in 24 hours. Build using online tutorials.

More Project Ideas on Python

Face recognition using Raspberry Pi
Linux Based Medication remainder
Ultrasonic beats player
Automated door opener with lighting control
IoT based theft detection using Raspberry Pi
Wheelchair wih safety system
Raspberry Pi osilloscope
Health monitoring using Raspberry pi
Automatic Green house system
Wheel combined robotic suspension system
Bank Account Management System using SQL and C++
Content Aggregation Project using Python
URL Shortener
Develop An Expense Tracking System using Python
Mp3 Player using Python
Simple Chat room using Python
Folder sorter according to files extensions using Python
Batch Image editor using Python
Password Generator and Manager using Python
Web Scrapper (Amazon Price Tracker)
Bird Species detection using Python
Develop An Online CV Builder using Python
Online Job Portal using Python and SQL database
Social Media Site using Python (Django)
Driver Drowsiness detection using Python
Traffic recognition using python
Website Blocker using python
Speech Emotion Recognition using Python
Speed Typing test with Python
Gender and Age Detection using Python
Pharmacy management using Python
Virtual Notebook - Python project
Find My Professor
How to Develop a TIC TAC TOE game using Python
Admission tracking system
Assignment submission system using Python
Smart feedback system using Python
Data collection tool using Python
Language translator and converter using Python
Automatic Brand LOGO detection using Python
Rock, paper, scissor game using python
Youtube video downloader with Tkinter UI python project
Instagram bot using python
Desktop notifier app using python
Spotify song downloader using python
Jarvis Personal assistant using Python
Sound processing python project
Develop a Supermarket Billing System with Python
Desktop voice assistant project

Subscribe to receive more project ideas

Stay up-to-date and build projects on latest technologies