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 👇#RPSuser_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 shapeif user_option == 0:R_for_user = rockelif user_option == 1:P_for_user = paperelif user_option == 2:S_for_user = scissors#Prevention from garbage valuesR_for_comp=""P_for_comp=""S_for_comp=""#Assigning signs to specific variableif computer_random_num == 0:R_for_comp = rockelif computer_random_num == 1:P_for_comp = paperelif computer_random_num == 2:S_for_comp = scissorsif 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")