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

Rock Paper and Scissors

This document is a Python script for a Rock, Paper, Scissors game. It allows the user to input their choice and randomly generates a choice for the computer, then determines the winner based on the rules of the game. The script includes ASCII art representations of the choices and handles invalid inputs.

Uploaded by

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

Rock Paper and Scissors

This document is a Python script for a Rock, Paper, Scissors game. It allows the user to input their choice and randomly generates a choice for the computer, then determines the winner based on the rules of the game. The script includes ASCII art representations of the choices and handles invalid inputs.

Uploaded by

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

import random

rock = '''

_______

---' ____)

(_____)

(_____)

(____)

---.__(___)

'''

paper = '''

_______

---' ____)____

______)

_______)

_______)

---.__________)

'''

scissors = '''

_______

---' ____)____

______)

__________)

(____)

---.__(___)

'''

game_images = [rock, paper, scissors]

# User's choice

user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors: "))
if user_choice >= 3 or user_choice < 0:

print("You typed an invalid number. You lose!")

else:

print("You chose:")

print(game_images[user_choice])

# Computer's choice

computer_choice = random.randint(0, 2)

print("Computer chose:")

print(game_images[computer_choice])

# Game logic

if user_choice == 0 and computer_choice == 2:

print("You win!")

elif user_choice == 2 and computer_choice == 0:

print("You lose!")

elif computer_choice > user_choice:

print("You lose!")

elif user_choice > computer_choice:

print("You win!")

else:

print("It's a draw!")

You might also like