Rock paper scissors game using python programming
Hello all.
are you bored of playing the old and rigid games???.
want to design a new game to play on your own???.
here im giving a way to design a single player game called Rock, Paper, Scissors which is often played between two friends.
About the game:
from our childhood we are all familiar with Rock Paper Scissor game. the basic rules to play this game is A rock beats scissors, scissors beat paper by cutting it, and paper beats rock by covering it.
lets make it more simple "why can't you play this game using python interpreter without installing any packages??"
just follow this simple steps:
- open Python IDE.
- copy the code which im providing here.
- run the code.
#rock paper scissors game
import random
print("welcome to the game.")
user = input("type your name here: ")
print("hello", user, "lets start the game choose one")
print("to stop the game type 'quit' ")
while True:
player = input("rock, paper, scissors? : ")
computer = random.choice(['rock','paper','scissors'])
if player == computer:
print("Tie!")
elif player == "rock":
if computer == "paper":
print("you lose!", computer, "covers", player)
else:
print("you win", player, "smashes", computer)
elif player == "paper":
if computer == "scissors":
print("you lose!", computer, "cuts", player)
else:
print("you win", player, "covers", computer)
elif player == "scissors":
if computer == "rock":
print("you lose!", computer, "smashes", player)
else:
print("you win", player, "cut", computer)
elif player == "quit":
print("thanks for playing see you again ")
break
else:
print("check your spelling!")
About the code:
this code using a basic module called random module. It is also uses basic if else statements which is easily understandable(be careful with indentation errors).
HAVE FUN!!!!
comment down if you face any issue regarding this project.
git-hub: https://github.com/manikanta-hub/rock_paper_seccissors.git
www.basicpythonprogramme.blogspot.com
ReplyDeletewww.basicpythonprojects.blogspot.com
ReplyDelete