Build Rock Paper,Scissors Game Using Python

Welcome to the Blog !! Let's build a "Rock Paper Scissors Game" by using Python. 

In this tutorial we will used some basics concept of python like ,
👉While Loop
👉If - Else Statement

Problem Statement :

  • To Build a "Rock Paper Scissors" Game.
  • Input - The list contain a string like , ["rock","paper","scissors"].
  • Output - The output will be display in the form of "You Lose or You Win".
💭 Concept of game :
  •  In this game only two players can be participated and both can simultaneously play the  game. 
  •  Rock can be referred as simple fist.  
  •  Paper can be referred to a flat hand.  
  •  Scissor can be referred as a fist with the index and middle of two fingers in the 'v' form.    
           Rules:                  
                 * Rock beats Scissors
                 * Scissors beats Paper
                 * Paper beats Rock.
 
★ Logic :
      
  1.   If player select rock and computer randomly also provide rock then it will display "Tied".
  2.   If player select  rock and computer randomly provide paper then it will display "You Lose otherwise "You Win".     
  3.   If player select rock and computer randomly provide scissors then it will display "You Win" otherwise "You Lose".  
  4.   If player select scissors and computer randomly provide paper then it will display "You Win" otherwise "You Lose". 
                
💻Let's Code :
       Here we will used Python IDLE for this project , So first install it on your system.
         Step 1 : Download python from official python website
  1.  Type python.org  in search bar.
  2.  Then go to the Downloads , there are latest version of python are available  for different   operating system such as windows , linux.
  3.  For windows , click on Downloads and select Windows , Now you can see at the top and click   on that link  Latest Python 3 Release - Python 3.8.5.
  4.  Scroll to the bottom and select either Windows x86-64 executable installer for 64-   bit or Windows x86 executable installer for 32-bit.                   
         Step 2 : Install python on your PC
  1. After downloading python involves downloading appropriate installer for your operating  system and running in your machine.
  2. Once have you chosen and downloaded and installer,simply run it by double click on the downloaded file.
  3. Then dialogue should open and click on Install Now. Once the installation is completed your all sets to work with IDLE.
  4. Then type idle in search bar and click on the same then the first screen should be open it's called as IDLE SHELL OR PYTHON SHELL.
fig 1: Python Shell

    ★ Note : 

  •   This Python Shell allows you to write code but it's not applicable to                        multiline programs on this shell. 
  •   For that multiline program go to the file option and select New File.        

             

fig 2 : Second Screen for multiline programs
    

   💥  Implementation :                                           

       First import the random module,the random module which is used for random operations. 
            
                                  



     ✔   Then create list and assign to the one of the variable.
            Here there are two variable we will used one is user and other one is computer.
                                     
         

                       
   ✔   Apply the logic according to the rule by using while loop and if-else statement. 

     
fig 3 : rock,paper,scissors.py

 

😉  Output:


fig 4 : Output 1


                                                                  
             
fig 5 : Output 2



          Yeahh ! we are done with the first python project 😃😄
         Hopes you understand and like the post 💬💬

         ALL THE BEST👍👍
           




Post a Comment

Comments :

Previous Post Next Post