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.
* Rock beats Scissors
* Scissors beats Paper
* Paper beats Rock.
★ Logic :
- If player select rock and computer randomly also provide rock then it will display "Tied".
- If player select rock and computer randomly provide paper then it will display "You Lose " otherwise "You Win".
- If player select rock and computer randomly provide scissors then it will display "You Win" otherwise "You Lose".
- 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
- Type python.org in search bar.
- Then go to the Downloads , there are latest version of python are available for different operating system such as windows , linux.
- 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.
- 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
- After downloading python involves downloading appropriate installer for your operating system and running in your machine.
- Once have you chosen and downloaded and installer,simply run it by double click on the downloaded file.
- Then dialogue should open and click on Install Now. Once the installation is completed your all sets to work with IDLE.
- 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.
Hopes you understand and like the post 💬💬
ALL THE BEST👍👍
Tags:
Python