100 Days of Code (Python Course by Angela) Project 5

 RPS Challenge: Unleash Your Luck in Rock, Paper, Scissors





Introduction:

This Game is created in Python Programming Language.
Welcome to the exciting world of Rock, Paper, Scissors! This project brings the classic game to life using Python programming. Challenge yourself against the computer in a battle of wits and luck as you determine who emerges victorious.

The program prompts the user to select their move by entering 0 for Rock, 1 for Paper, or 2 for Scissors. The computer generates a random move using the random module, and the two choices are compared to determine the winner. The program then displays the chosen moves and the outcome of the game.

With engaging ASCII art representing each option, the visual presentation adds a touch of excitement to the gameplay. Whether you win, lose, or end up in a draw, this project offers a fun and interactive experience for players of all ages.
Source code:

rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
import random
#Write your code below this line 👇
#RPS
user_option = int(input("Type 0 for Rock, 1 for paper, 2 for scissors\n"))
computer_random_num = random.randint(0,2)
R_for_user =""
P_for_user =""
S_for_user =""
#Assigning user option to shape
if user_option == 0:
R_for_user = rock
elif user_option == 1:
P_for_user = paper
elif user_option == 2:
S_for_user = scissors
#Prevention from garbage values
R_for_comp=""
P_for_comp=""
S_for_comp=""
#Assigning signs to specific variable
if computer_random_num == 0:
R_for_comp = rock
elif computer_random_num == 1:
P_for_comp = paper
elif computer_random_num == 2:
S_for_comp = scissors
if user_option == 0 and computer_random_num == 2:
print(f"You choose {user_option} & Computer choose {computer_random_num}\n")
print(f"{rock}\n {scissors}")
print("You win")

elif user_option >= 3:
print("You have entered an invalid number. You lose.")
elif user_option < 0:
print("You have entered an unvalid number. You Lose. ")
elif user_option == 1 and computer_random_num == 0:
print(f"You choose {user_option} & Computer choose {computer_random_num}\n")
print(f"{paper}\n {rock}")
print("You win")
elif user_option == 2 and computer_random_num == 1:
print(f"You choose {user_option} & Computer choose {computer_random_num}\n")
print(f"{scissors}\n {paper}")
print("You win")
elif user_option == computer_random_num:
print(f"You choose {user_option} & Computer choose {computer_random_num}\n")
print(f"{R_for_user} {P_for_user} {S_for_user}\n")
print("----------------------")
print(f"{R_for_comp} {P_for_comp} {S_for_comp}\n")
print("its a Draw ")
else:
print(f"You choose {user_option} & Computer choose {computer_random_num}\n")
print(f"{R_for_user} {P_for_user} {S_for_user}\n")
print("----------------------")
print(f"{R_for_comp} {P_for_comp} {S_for_comp}\n")
print("You lose")


Next Post Previous Post