https://github.com/fahadelahikhan/rock-paper-scissors-python
A simple Python script to play the classic Rock-Paper-Scissors game. Test your luck and challenge the computer!
https://github.com/fahadelahikhan/rock-paper-scissors-python
beginner-project command-line-game game interactive-game programming-practice python python-script python3 rock-paper-scissors simple-game
Last synced: 10 months ago
JSON representation
A simple Python script to play the classic Rock-Paper-Scissors game. Test your luck and challenge the computer!
- Host: GitHub
- URL: https://github.com/fahadelahikhan/rock-paper-scissors-python
- Owner: fahadelahikhan
- License: mit
- Created: 2024-08-26T15:53:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-13T09:33:46.000Z (10 months ago)
- Last Synced: 2025-03-13T10:32:09.654Z (10 months ago)
- Topics: beginner-project, command-line-game, game, interactive-game, programming-practice, python, python-script, python3, rock-paper-scissors, simple-game
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rock-Paper-Scissors Python 🪨📄✂️


A simple command-line implementation of the classic Rock-Paper-Scissors game in Python.
## 📜 About
This project implements the traditional Rock-Paper-Scissors game where players compete against a computer opponent. The game follows standard rules where rock beats scissors, scissors beat paper, and paper beats rock. It's an excellent example of basic game logic and user input handling in Python.
## ✨ Features
- Classic Rock-Paper-Scissors gameplay
- Random computer opponent selection
- Simple command-line interface
- Input validation for user choices
- Clear win/lose/draw conditions
## 🚀 Quick Start
### Installation
1. Clone the repository:
```bash
git clone https://github.com/fahadelahikhan/Rock-Paper-Scissors-Python.git
cd Rock-Paper-Scissors-Python
```
2. Run the game:
```bash
python "Rock Paper Scissors.py"
```
### Basic Usage
```python
# Import the game function
from rock_paper_scissors import play_game
# Start a new game
play_game()
# Choose your move by entering 0, 1, or 2
# 0 for Rock, 1 for Paper, 2 for Scissors
```
### Example Game Session
```python
# User chooses Paper (1)
user_choice = 1
# Computer randomly selects Rock (0)
computer_choice = 0
# Determine the winner
if (computer_choice == 0 and user_choice == 1):
print("You Win!")
elif (computer_choice == user_choice):
print("Draw!")
else:
print("You lose!")
# Display choices
print(f"Your choice is: {Expression[user_choice]}")
print(f"Computer choice is: {Expression[computer_choice]}")
```
## 📖 How It Works
The game logic is based on simple conditional statements:
- If the user's choice beats the computer's choice according to standard rules, the user wins
- If both choices are the same, it's a draw
- Otherwise, the computer wins
The computer's choice is generated using Python's `random.randint(0, 2)` function, ensuring a fair random selection.
## ⚖️ License
Distributed under the MIT License. See [LICENSE](LICENSE) for details.
---
> **Note**: This implementation is for educational and entertainment purposes. The game uses a simple random algorithm for the computer opponent, which is not cryptographically secure.