Rock, Paper and Scissors Game in Python

 


Hey friends, today in this blog you’ll learn how to make a Working game in Python. I’ll use the only Python to create this game. Its name is rock, paper, scissors. In the earlier blog, I have shared how to find areas of a rectangle using Python and it’s time to create a game using Python.

It is a game for children and it is also for those who are finding some mini project in Python. In this game, we take input from the user. If the user enters R then it means he has chosen Rock and if he enters P then it means he has chosen Paper last but not least if the user enters S then it means he has chosen Scissor

You might like this:

Here is the concept of the game



Here is the Source Code of the game

#------------ Created by Coding Gyan -------------
import random
#------------ Rock, Paper, and Scissors -------------

def whoWin(comp, you):
    if comp==you:
        return None
    elif comp=='s':
        if you=='p':
            return False
        elif you=='r':
            return True
    elif comp=='p':
        if you=='r':
            return False
        elif you=='s':
            return True
    elif comp=='r':
        if you=='s':
            return False
        elif you=='p':
            return True

comp = print('Computer\'s turn: Choose Rock(r), Papaer(p) and Scissors(s)')
you = input('Your turn: Choose Rock(r), Papaer(p) and Scissors(s) => ')

random = random.randint(1, 3)

if random==1:
    comp = 'r'
elif random==2:
    comp = 'p'
else:
    comp = 's'

w = whoWin(comp, you)

if w==True:
    print('You win the Game:)')
elif w==False:
    print('You loss the Game!')
else:
    print('The Game is Draw')


 

Please Comment Down Your Feedback

Thanks For Visiting our Blog

Post a Comment

Previous Post Next Post