DEV Community

Cover image for New to Python? Here is a fun project to help you get  started.
Dhanya Hegde
Dhanya Hegde

Posted on


New to Python? Here is a fun project to help you get started.


I think all of us have played this game when we were kids and
still do play it to decide who goes first in doing something.
How about creating your own virtual rock, paper, scissors game
in python? Sounds exciting right?

The best part about creating this game is that you don't have to be a professional in Python.

You just have to know certain basics about conditional
statements like if, elif, then using the input function and the random module.

Try it out on your own or take help from my code down below👇 .

My game is as beginner friendly as possible as I haven't used a lot of additional functionality to make it look better. If you are a little more familiar with python you can use images instead of numbers to make it look better.


import random
game_numbers = [0,1,2]

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

computer_choice = random.randint(0, 2)
print("Computer chose:")

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")

Top comments (0)