Rock Paper Scissors with Python

Rock Paper Scissors




This is a really fun Game made by using Python Programming Language.

*Featured Code submitted and Created by  Christine




'''Welcome to my code! I have created a rock paper scissors code to play with the computer. Here are the instructions:
    - Run the code, and type in 'rock', 'paper', or 'scissors' into the input.
    - If you type something like 'ROCK' into the input, it will not work so make sure to type in all lowercase letters.
    
    Also, if you would like to look at the code you can. If you can think of any way to shorten the code, please tell me in the comments. I used a very simple way to make this code. 
    
    
    Thank you, and I hope you enjoy it!  =D '''


Python



import random
userAction = input()
computerAction = random.randint(1, 3)

if userAction == "rock":
    if computerAction == 1:
        print("rock vs. rock:   TIE.   -_-")
    if computerAction == 2:
        print("rock vs. paper:   YOU LOSE...   >_<")
    if computerAction == 3:
        print("rock vs. scissors:   YOU WIN!!!   ^_^")
elif userAction != "paper" and userAction != "scissors":
    print("Please enter 'rock', 'paper', or 'scissors'.   :)")
    
if userAction == "paper":
    if computerAction == 1:
        print("paper vs. rock:   YOU WIN!!!   ^_^")
    if computerAction == 2:
        print("paper vs. paper:   TIE.   -_-")
    if computerAction == 3:
        print("paper vs. scissors:   YOU LOSE...   >_<")
        
if userAction == "scissors":
    if computerAction == 1:
        print("scissors vs. rock:   YOU LOSE...   >_<")
    if computerAction == 2:
        print("scissors vs. paper:   YOU WIN!!!   ^_^")
    if computerAction == 3:
        print("scissors vs. scissors:   TIE.   -_-")

Click here to run this Code and Play the Game


Share with Friends






More Free Code Examples:



Vigenere Cipher


Python Code to Convert Years to Days




Try these Fun Games by Bobbie:


Travel Blast Game New York


Play and Learn Russian


Battlestarship Game



Take a look at these Groovy Codes:


Fun IQ Test


Html Svg Starburst


Javascript Particles Fishes



Read the Latest Breaking Programming and Tech News, Great Articles and Tips:


Codenewz Programming and Tech News






Comments

Popular posts from this blog

Crypto Mining

Multi-tap Keypad Text Entry