Rock Paper Scissors using Python as the language, Slides of Programming Languages

This project is about a game usually played by two people, where players make one of three shapes with their hands at the same time. The "rock" beats scissors, the "scissors" beat paper and the "paper " beats rock; if both players throw the same shape, the game is tied

Typology: Slides

2021/2022

Uploaded on 11/17/2022

harshith-reddy-chandireddy
harshith-reddy-chandireddy 🇮🇳

1 document

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
II B.Tech II
Semester Python
Programming
Laboratory
COURSE BASED
PROJECT
PYTHON
ROCK PAPER SCISSOR
GAME
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Rock Paper Scissors using Python as the language and more Slides Programming Languages in PDF only on Docsity!

II B.Tech II

Semester Python

Programming

Laboratory

COURSE BASED

PROJECT

PYTHON

ROCK PAPER SCISSOR

GAME

TEAM

CONCEPTS USED

  • (^) Python concepts used :
1)if
2)elif
3)else
STEP-1:We first set up the game environment and import the
required library like import random. This random library will help in
picking random elements by providing various functions that are
capable of performing such operations.
Step-2:In second step we use the logic for giving writing the code
and how the computer should react to certain input given by the
user.

MORE DETAILS.... It’s easier for a computer to work with numbers. So, for this program, the computer will assign a number to each choice

  • ROCK=
  • PAPER=
  • SCISSORS= To choose the winner you have to compare the computer’s choice with the player’s choice.

CODE import random Cchoice = ["Rock", "Paper", "Scissor"] # list for computer while True: print("Rock Paper scissor Game:") youwin, computerwin = 0, 0 for i in range(1, 6): # 5 Round game print("Round", i, "Start:") print("Please select any one option:") print("1.Rock", "2.Paper", "3.Scissor", sep="\n") # choice any option but in number 1,2, Yourchoice = int(input()) if Yourchoice == 1: print("You select Rock") Yourchoice = "Rock" elif Yourchoice == 2: print("You select paper") Yourchoice = "Paper" elif Yourchoice == 3: print("You select scissor") Yourchoice = "Scissor" else: print("Invalid Choice") break

Computerchoice = random.choice(Cchoice) # random select by computer choice print("Computer select:", Computerchoice)

comparing result and give the point.

if Yourchoice == Computerchoice: youwin += 1 computerwin += 1 print("This Round is Draw:") elif (Yourchoice == "Paper" and Computerchoice == "Rock") or ( Yourchoice == "Rock" and Computerchoice == "Scissor") or ( Yourchoice == "Scissor" and Computerchoice == "Paper"): youwin += 1 print("You win this Round")

OUTPUT

CONCLUSION The end strategy of a simple Rock Paper Scissors game is to be random and fast. Statistically, each attack will tend to occur just as frequently as another ,given that each is equally effective. So, this was an easy and fun way to create a rock paper scissors game. It is customizable, as per a developer's personal preference. Not just rock paper and scissors game but many more games can be developed easily in Python using various tools and libraries available.