scissors game

Make a rock, paper, scissors game in Python

Make a rock, paper, scissors game in Python

Hello Coder, welcome to the codewithrandom blog. In this article, we create a rock , paper , scissors game using python programming  with Complete Source Code.

Make a rock, paper, scissors game in Python

what is rock , paper , scissors game ?

Rock Paper Scissors is a popular game played between two people, where each player selects one of three options: rock, paper, or scissors. The winner is determined by the rules that rock beats scissors, scissors beat paper, and paper beats rock.

 

How To Run The Code :

step 1: open any python code Editor.

step 2:  Make a python file main.py

step 3:  import random module

step 4:  Copy the code & Past it

step 5:  Run the file main.py and your program will run

How to build a calculator using python

Create Your Own Email Sender App Using Python

 

#program code 👇👇👇👇👇👇

# import random module
import random

# print multiline instruction
rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''

game_images = [rock, paper, scissors]

# take the input from user
user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))

print(game_images[user_choice])

computer_choice = random.randint(0, 2)
print("Computer chose:")
print(game_images[computer_choice])
#Using an ifelif else block, you can compare players’ choices and determine a winner: if user_choice >= 3 or user_choice < 0: print("You typed an invalid number, you lose!") elif user_choice == 0 and computer_choice == 2: print("You win!") elif computer_choice == 0 and user_choice == 2: print("You lose") elif computer_choice > user_choice: print("You lose") elif user_choice > computer_choice: print("You win!") elif computer_choice == user_choice: print("It's a draw")

You’ve now written code to take in user input, select a random action for the computer, and decide the winner!

 Program Output 👇👇👇👇

Make a rock, paper, scissors game in Python

Thanks for following along with this project tutorial. I hope you learned something while making the rock, paper, scissors game in python .

#rock, paper, scissors game



Leave a Reply