Link to code: https://colab.research.google.com/drive/1zRVT20MhXBPmbU2OTtkjhJy_xtmiKGSi?usp=sharing
I am new to coding, so for my first project, I chose to create a simple Rock, Paper, Scissors game. This game was a good way for me to practice the basics of Python, such as functions, loops, and conditional statements. I also wanted to make sure the program was user-friendly, so I added clear messages, error checking, and a replay option to make it easy to use.

-flow chart of the code
PT.1: FUNCTIONS
def play_rock_paper_scissors():
When the game begins, it prints a welcome message to introduce the game and let the player know they will be playing against the computer.
PT.2: INTRODUCTION AND LOOP
print(" Let's Play Rock, Paper, Scissors! ")
print("You will play against the computer.")
while True:
When the game begins, it prints a welcome message to introduce the game and let the player know they will be playing against the computer.
Next, I set up a loop using while True
, which repeats the game over and over until the player decides to stop. This way, the player can play multiple rounds without restarting the program.
PT.3: PLAYER CHOICE
player_choice = input("Enter your choice (rock, paper, or scissors): ").lower()
if player_choice not in ["rock", "paper", "scissors"]:
print("Invalid choice! Please type rock, paper, or scissors.")
continue
The input()
part pauses the game and waits for the player to type something. The program asks the player to type rock, paper, or scissors. I added .lower()
so it works even if the player types capital letters like “Rock.”
If the player types something invalid (like “banana”), the program prints a warning and restarts the round. This prevents the game from crashing and keeps it friendly.
PT.4:COMPUTER CHOICE
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
Here, options
is a list that stores the three possible choices. random.choice(options)
picks one of them randomly. This makes the computer’s choice fair and unpredictable.
PT.5: DISPLAYING CHOICES
print(f"You chose: {player_choice}")
print(f"The computer chose: {computer_choice}")
These lines show the player what they chose and what the computer chose, so the player can clearly see both sides before the winner is announced.
PT.6: DECIDING THE WINNER
if player_choice == computer_choice:
print("It's a tie! 🤝")
The if statement checks a condition. If it’s true, Python runs the code inside that block. This line checks if the player and the computer chose the same thing. If they did, it prints “It’s a tie!” If they didn’t, Python moves to the next check.
elif (player_choice == "rock" and computer_choice == "scissors") or \
(player_choice == "scissors" and computer_choice == "paper") or \
(player_choice == "paper" and computer_choice == "rock"):
print("You win! 🎉")
elif
stands for “else if.” It gives another condition to check if the previous if
(or another elif
) was false.
This line is checked only if the if condition wasn’t true (so it wasn’t a tie). The program looks at all the situations where the player would win. If any of these are true, it prints “You win!”
else:
print("The computer wins! 💻")
The else
statement is the catch-all. It runs only if none of the previous if
or elif
conditions were true.
This means if it wasn’t a tie (if
) and the player didn’t win (elif
), then the computer must have won. It doesn’t need a condition because it automatically handles all remaining possibilities.
PT.7: PLAY AGAIN OPTION
play_again = input("Do you want to play again? (yes/no): ").lower()
if play_again != "yes":
break
The first line asks for input and converts it to lowercase so that “Yes” or “YES” also works. The second line checks if the player typed anything other than “yes.” If they did, the break
command stops the loop and ends the game.
PT.8: ENDING THE GAME
print("Thanks for playing! Goodbye!")
When the player decides to stop, the program prints a goodbye message to signal the end of the game.
PT.9: RUNNING THE FUNCTION
play_rock_paper_scissors()
This line is important because it actually starts the game; without it, Python would just know the instructions inside the function but would never run them, so the player wouldn’t see or play the game.
Reflection:
In summary, I think I did a great job on this project. Even though it is a simple game, it is fun and interactive, and I am proud of creating it. This project helped me practice basic coding skills like functions, loops, variables, and conditional statements, and it taught me how to make a program user-friendly and responsive to input. It gives me confidence as a beginner in coding.
Leave a Reply