D63 and D64 #100DaysOfCode

D63 and D64 #100DaysOfCode. I made a Rock, Paper Scissors game in Python without using Google.

Read Time1 Minute, 16 Seconds

These days are just flying by now before I know it I’ll be at 100 days.

So I was looking procrastinating from doing my Django learning and found myself building a Rock, Paper, Scissors game and I wanted to see if I could make the entire thing from scratch without using Google.

I concept is simple, the computer picks either R, P or S from a list and then the player will select their choice of R, P or S and based on the rules of the game you would either win, tie or lose.

The cool thing about this idea is that there are so many different ways you can program this.

Below is the game in action.

And here is the code, as well as the GitHub link.

import random

def main():
    if userChoice == "r":
        choiceR()
    elif userChoice == "p":
        choiceP()
    elif userChoice == "s":
        choiceS()
    else:
        print("Error.")

def choiceR():
    if choice == "r":
        print("You Tied")
    elif choice == "p":
        print("You lose")
    elif choice == "s":
        print("You Win!")
    else:
        print("Error.")

def choiceP():
    if choice == "p":
        print("You Tied")
    elif choice == "s":
        print("You lose")
    elif choice == "r":
        print("You Win!")
    else:
        print("Error.")

def choiceS():
    if choice == "s":
        print("You Tied")
    elif choice == "r":
        print("You lose")
    elif choice == "p":
        print("You Win!")
    else:
        print("Error.")

if __name__ == "__main__":
    while True:
        rps = ["r", "p", "s"]
        choice = random.choice(rps)
        userChoice = input("Select [R]ock, [P]aper, or [S]cissors: ").lower()
        main()

I would love to hear how you would go about making this!

1 0
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Leave a Reply

Your email address will not be published. Required fields are marked *

Close