0% found this document useful (0 votes)
52 views11 pages

Rps Mini Project Final - Removed

This Python program simulates the classic game of Rock, Paper, Scissors between a user and the computer. The computer randomly selects its choice while the user inputs theirs, and the program determines the winner based on the game's rules. It allows for multiple rounds of play and demonstrates basic Python concepts.

Uploaded by

Dhanya Sonu
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)
52 views11 pages

Rps Mini Project Final - Removed

This Python program simulates the classic game of Rock, Paper, Scissors between a user and the computer. The computer randomly selects its choice while the user inputs theirs, and the program determines the winner based on the game's rules. It allows for multiple rounds of play and demonstrates basic Python concepts.

Uploaded by

Dhanya Sonu
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/ 11

ABSTRACT

This project involves the development of a Python program to simulate the classic game Rock, Paper, Scissors. The
game is designed for a single user to play against the computer, which generates its moves randomly. Key features
of the program include:

- Random Choice Generation: The computer's move is selected randomly from the three possible options: rock,
paper, or scissors.
- User Input Handling: The program accepts the user's input, ensuring it is valid and prompting for re-entry if
necessary.
- Game Logic Implementation: The program determines the outcome of each round based on the established rules
of Rock, Paper, Scissors:
- Rock crushes Scissors
- Scissors cuts Paper
- Paper covers Rock
- Result Display: After each round, the program displays the choices made by both the user and the computer, and
announces the winner or if the round is a tie.
- Replay Option: The user is given the option to play multiple rounds until they decide to quit.

The program demonstrates fundamental programming concepts such as input validation, control structures (loops
and conditionals), and random number generation, making it an excellent exercise for beginners learning Python.
The simplicity of the game's rules combined with the interactive nature of the program provides a practical and
engaging way to understand basic programming principles.

i
CONTENTS

TITLE Page no.


ABSTRACT i
1. Chapter 1: INTRODUCTION 1-3
1.1 Objectives 1
1.2 Background Information 2
1.3 Scope and Limitation 2
1.3.1 Scope 2
1.3.2 Limitations 3
2. Chapter 2: METHODOLOGY 4-7
2.1 Methods and Techniques 4
2.1.1 Methods 4
2.1.2 Techniques 4
2.2 Tools, Software and Materials 4-5
2.2.1 Tools and Software 4
2.2.2 Materials 5
2.3 Data Collection and Analysis Procedures 5
2.3.1 Data Collection 5
2.3.2 Analysis Procedures 5
2.4 Flowchart 6
2.5 Program 7
3. CHAPTER 3: RESULT 8
3.1 OUTPUT 8
3.1.1 Output of all possibilities of program 8

3.1.2 Output of all possibilities of rock , paper , scissors game 8

4. CONCLUSION 9

ii
ROCK, PAPER AND SCISSORS 2023-24

CHAPTER 1

INTRODUCTION

This program allows you to play the classic hand game against the computer. The rules are simple:
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
In this program, you will be prompted to enter your choice of "Rock", "Paper", or "Scissors". The computer will then
randomly select its choice, and the winner will be determined based on the rules above. The result of each game will
be displayed, and you will have the option to play again or exit the game.
This project is a fun way to practice basic Python concepts such as:
- User input and output
- Random number generation
- Conditional statements
- Loops
This introduction sets the stage for the user, explaining what the program does, the basic rules of the game, and the
Python concepts involved.
1.1 OBJECTIVE

The objective of this Python program is to simulate the traditional game of Rock, Paper, Scissors, allowing a user to
play against the computer. The program aims to:

1. Provide an Interactive Experience: Engage the user by prompting for their choice and displaying the computer’s
choice and the outcome of each round.
2. Practice Basic Python Skills: Help learners practice essential Python programming skills, including handling user
input, generating random choices, using conditional statements to determine the winner, and implementing loops for
repeated play.
3. Enhance Problem-Solving Abilities: Develop problem-solving skills by translating the game rules into a functional
program logic.
4. Deliver a Fun and Educational Tool: Offer an enjoyable and educational experience that can be extended or
modified for further learning and experimentation with Python.

Page 1|9
1
ROCK, PAPER AND SCISSORS 2023-24

1.2Background Information

Rock, Paper, Scissors is a simple hand game that is often used as a decision-making tool, much like flipping a coin
or drawing straws. The game is believed to have originated in China over 2,000 years ago and has spread globally,
becoming a popular method for resolving minor conflicts and making decisions in a fun and fair way.

In recent years, the game has been adapted into various digital formats, including simple programs and apps.
Implementing Rock, Paper, Scissors in Python is an excellent beginner project for those learning programming. It
introduces fundamental concepts such as:
- User input and validation
- Random number generation and its application in simulating choices
- Conditional logic for determining the outcome
- Looping structures for repeated interactions

This project not only serves as an entertaining game but also as an educational exercise to solidify these basic
programming concepts.

1.3Scope and Limitations

1.3.1Scope
The scope of this Rock, Paper, Scissors program includes:
1. User Interaction: Prompting the user to input their choice (Rock, Paper, or Scissors) and providing feedback
based on the computer's random choice.
2. Random Choice Generation: Using Python's random module to simulate the computer's choice, ensuring an
unpredictable and fair game.
3. Game Logic Implementation: Applying the rules of Rock, Paper, Scissors to determine the winner of each
round.
4. Replayability: Allowing the user to play multiple rounds in a single session and providing an option to exit the
game.
5. User-Friendly Output: Displaying clear and concise messages about the choices made and the result of each
round.

Page 2|9
ROCK, PAPER AND SCISSORS 2023-24

1.3.2 Limitations
The limitations of this project include:
1. Simplicity: The program is designed to be straightforward and may not include advanced features such as a
graphical user interface (GUI) or multiplayer capabilities.
2. Input Validation: While basic input validation is implemented, it might not handle all possible incorrect inputs
gracefully.
3. Statelessness: The program does not maintain state across sessions, meaning it does not keep track of scores or
history once the program is closed.
4. Limited Interactivity: The game is restricted to a single user playing against the computer, without options for
player vs. player or network play.
5. Educational Focus: As an educational tool, the program prioritizes simplicity and clarity over performance
optimizations or complex features.
This section provides a thorough overview of the background, scope, and limitations of the project, giving context to

its development and helping to manage expectations regarding its capabilities .

Page 3|9
ROCK, PAPER AND SCISSORS 2023-24

CHAPTER 2

METHODOLOGY

2.1Methods and Techniques


2.1.1 Methods
The Rock, Paper, Scissors Python program employs several fundamental programming methods and techniques:
1. User Input and Output: The program uses the `input()` function to capture the user's choice and `print()`
statements to display messages and results.
2. Random Choice Generation: The `random` module is utilized to simulate the computer's choice. Specifically, the
`random.choice()` function selects from a list of options ('Rock', 'Paper', 'Scissors').
3. Conditional Statements: `if`, `elif`, and `else` statements determine the outcome of each round based on the game
rules.
4. Loops: A `while` loop allows the game to be played repeatedly until the user decides to quit.
5. Functions: Encapsulating the game logic and user interactions within functions improves code readability and
reusability.

2.1.2Techniques
1. Input Validation: Ensuring the user inputs a valid choice (i.e., 'Rock', 'Paper', or 'Scissors') and handling invalid
inputs gracefully.
2. Randomization: Using random selection to simulate fair and unpredictable computer choices.
3. Result Determination: Implementing game logic to compare choices and determine the winner.
4. Replayability: Providing a mechanism for the user to play multiple rounds in a single session.

2.2Tools, Software, and Materials

2.2.1Tools and Software


1. Python Programming Language: The core language used to write and run the program. Python is chosen for its
simplicity and readability, making it ideal for beginners.
2. Python `random` Module: Utilized to generate random choices for the computer.
3. Text Editor/IDE: Software such as VS Code, PyCharm, or even simple text editors like Notepad++ to write and
edit the Python code.

Page 4|9
3
ROCK, PAPER AND SCISSORS 2023-24

4. Command Line/Terminal: Used to run the Python script and interact with the program.

2.2.2Materials
1. Documentation: Python's official documentation and tutorials for understanding syntax and module functionalities.
2. Online Resources: Websites like Stack Overflow, Python community forums, and educational platforms for
troubleshooting and learning best practices.

2.3 Data Collection and Analysis Procedures


2.3.1 Data Collection
1. User Inputs: Collecting the user's choice each round through the `input()` function.
2. Computer choice: Generating and recording the computer's choice using `random.choice()`.

2.3.2Analysis Procedures
1. Outcome Determination: Analyzing the user's and computer's choices using conditional statements to determine
the winner of each round.
2. Result Tracking: Although the basic version of the program does not store results between sessions, within a
session, results can be tracked to provide feedback after each round.
3. User Feedback: Providing immediate feedback to the user after each round, indicating their choice, the computer's
choice, and the round's outcome.

This section provides a detailed overview of the methods and techniques used in the project, the tools and software
required, and the procedures for data collection and analysis. This information is essential for understanding the
structure and execution of the program.

Page 5|9
ROCK ,PAPER AND SCISSORS 2023-24

3.4 FLOW CHART


The below flow chart shows the all the conditions and the outcomes of the game rock, paper and scissors

Detailed flow chart of the rock,paper and scissors game

Page 6|9
Dept ISE,BGSIT 4
2023-24

3.4PROGRAM:

from random import randint

#create a dictionary of play options


t = {0:"rock", 1:"paper", 2:"scissors"}

#assign a random play to the computer


computer = t[randint(0,2)]

#set player to False


player = False

while player == False:


#set player to True
player = input("Rock, Paper, Scissors?:").lower().strip()
if player == computer:
print("Tie!")
elif player == "rock":
if computer == "paper":
print("You lose!", computer, "covers", player)
else:
print("You win!", player, "smashes", computer)
elif player == "paper":
if computer == "scissors":
print("You lose!", computer, "cut", player)
else:
print("You win!", player, "covers", computer)
elif player == "scissors":
if computer == "rock":
print("You lose...", computer, "smashes", player)
else:
print("You win!", player, "cut", computer)
else:
print("That's not a valid play. Check your spelling!")
#player was set to True, but we want it to be False so the loop continues
player = False
computer = t[randint(0,2)]

Page 7|9
Dept of ISE,BGSIT 5
2023-24

CHAPTER 3

RESULT
3.1 OUTPUT:
Here below image shows the various scenarios like where you loose , in which
scenario you win, when there is a tie, and also what message will be displayed when you
enter incorrect input.
 Back-End : MySQL

 Web Server : Apache S

Fig3.1.1 output of all possibilities of program

Fig 3.1.2. output of all possibilities of rock , paper and scissors


game

Page 8|9
Dept of ISE,BGSIT 6
ROCK,PAPER AND SCISSORS 2022-23

CONCLUSION

Creating a rock, paper, scissors game in Python demonstrates the language's ease of use and accessibility for
beginners. This project covers fundamental programming concepts such as conditional statements, loops, user
input, and random number generation. Python's straightforward syntax allows developers to focus on learning
these core concepts without being bogged down by complex code. Overall, implementing a rock, paper,
scissors game in Python is an excellent way to introduce essential programming skills in an engaging and
practical manner..

Page 9|9
Dept ISE,BGSIT

You might also like