0% found this document useful (0 votes)
15 views2 pages

Rock Paper Scissor

This document contains a Python program for a Rock, Paper, Scissors game. It includes ASCII art representations for each choice, functions to get user input, generate a random computer choice, and determine the winner. The game is played in a loop until the user decides to stop.

Uploaded by

Puttipongtorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Rock Paper Scissor

This document contains a Python program for a Rock, Paper, Scissors game. It includes ASCII art representations for each choice, functions to get user input, generate a random computer choice, and determine the winner. The game is played in a loop until the user decides to stop.

Uploaded by

Puttipongtorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import random

# ASCII Art
rock = """
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
"""

paper = """
_______
---' ____)____
______)
_______)
_______)
---.__________)
"""

scissors = """
_______
---' ____)____
______)
__________)
(____)
---.__(___)
"""

# Map choices to ASCII art


ascii_art = {
"rock": rock,
"paper": paper,
"scissors": scissors
}

# Get user input


def get_user_choice():
choice = input("Enter Rock, Paper, or Scissors: ").lower()
while choice not in ascii_art:
print("Invalid choice. Try again.")
choice = input("Enter Rock, Paper, or Scissors: ").lower()
return choice

# Get computer's random choice


def get_computer_choice():
return random.choice(["rock", "paper", "scissors"])

# Decide winner
def determine_winner(user, computer):
if user == computer:
return "It's a tie!"
elif (user == "rock" and computer == "scissors") or \
(user == "paper" and computer == "rock") or \
(user == "scissors" and computer == "paper"):
return "You win!"
else:
return "Computer wins!"
# Play game
def play_game():
print("=== Rock Paper Scissors ===")
user_choice = get_user_choice()
computer_choice = get_computer_choice()

print(f"\nYou chose:\n{ascii_art[user_choice]}")
print(f"Computer chose:\n{ascii_art[computer_choice]}")

print(determine_winner(user_choice, computer_choice))

if __name__ == "__main__":
play_game()

You might also like