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

PDF python

This document provides a simple Rock-Paper-Scissors game implemented in Python. The game allows the user to input their choice and compares it with a randomly generated choice from the computer, determining the outcome of each round. Users can choose to play again or exit the game after each round.

Uploaded by

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

PDF python

This document provides a simple Rock-Paper-Scissors game implemented in Python. The game allows the user to input their choice and compares it with a randomly generated choice from the computer, determining the outcome of each round. Users can choose to play again or exit the game after each round.

Uploaded by

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

Here’s a simple Rock-Paper-Scissors game in Python:

```

import random

print(”Rock-Paper-Scissors Game!”)

while True:

user_choice = input(”Enter your choice (rock/paper/scissors): “)

possible_choices = [”rock”, “paper”, “scissors”]

computer_choice = random.choice(possible_choices)

print(f”\nYou chose {user_choice}, computer chose {computer_choice}.\n”)

if user_choice == computer_choice:

print(f”Both players selected {user_choice}. It’s a tie!”)

elif user_choice == “rock”:

if computer_choice == “scissors”:

print(”Rock smashes scissors! You win!”)

else:

print(”Paper covers rock! You lose.”)

elif user_choice == “paper”:

if computer_choice == “rock”:

print(”Paper covers rock! You win!”)

else:

print(”Scissors cuts paper! You lose.”)

elif user_choice == “scissors”:

if computer_choice == “paper”:

print(”Scissors cuts paper! You win!”)


else:

print(”Rock smashes scissors! You lose.”)

play_again = input(”Play again? (yes/no): “)

if play_again.lower() != “yes”:

break

```

Just copy and paste this code into a Python file, and you’re ready to play!

You might also like