Python Micro
Python Micro
ON
Rock, Paper, Scissors Game Using Python
Session:- 2024-25
Submitted By:-
Rock, Paper, Scissors game is a simple yet fun hand game played between two
participants, often used as a decision-making tool. In this Python-based version, the
game allows a user to compete against the computer. The player selects Rock, Paper,
or Scissors, and the computer randomly generates its choice. The winner is determined
based on the classic rules: Rock beats Scissors / Scissors beats Paper / Paper beats
Rock
The Rock Paper Scissors game is a simple yet engaging project demonstrating
randomization, GUI development, event handling, conditional logic, user
interaction, and real-time feedback. Implemented in Python using the Tkinter
library, it allows users to select moves and compete against a randomly generated
computer choice. The game logic follows standard rules, comparing choices to
determine the winner. Future enhancements can include animations, score
tracking, and multiplayer functionality for a better experience.
lambda → Used in command=lambda x=choice: self.play(x) for passing arguments to the function inside a
button click.
pack → Used for arranging buttons and labels in the Tkinter window (.pack(pady=10)).
random → Used for generating the computer's choice (random.choice([...])).
config → Used to update labels dynamically (self.result_label.config(text="...")).
tk → Tkinter module, used to create the GUI (import tkinter as tk).
title → Sets the window title (self.window.title("Rock Paper Scissors - 3 Rounds")).
geometry → Sets window size (self.window.geometry("300x300")).
window → Refers to the Tkinter window instance (self.window = tk.Tk()).
__init__ → Constructor method used to initialize class variables.
5.0 PROPOSED METHODOLOGY
Start
Create the main window using Tkinter and set the title and size.
Retrieve the "Rock", "Paper", and "Scissors" buttons using Tkinter’s Button widget.
Define a label to display instructions for the user.
Define an empty label (result_label) to display the game result.
Create an event listener for each button that triggers when clicked.
Inside the event:
o Get the player's choice from the clicked button.
o Generate the computer's choice randomly from the list: ['Rock', 'Paper',
'Scissors'].
o Compare the player's choice with the computer's choice:
If both choices are the same, display "It's a Tie!".
If the player wins based on game rules, display "You Win!".
Otherwise, display "Computer Wins!".
o Update the result_label to show the choices and the result.
Start the Tkinter main event loop to run the application.
End
2. Software MS Word
1 Discuss About The Topic Jan 20, 2025 Jan 22, 2025
3 Discuss with Project Guide Jan 27, 2025 Jan 29, 2025
:
\
PART B:- Micro-Project Proposal
1. Rationale
4. Literature Review
The Rock Paper Scissors game is a simple yet engaging project demonstrating
randomization, GUI development, event handling, conditional logic, user
interaction, and real-time feedback. Implemented in Python using the Tkinter
library, it allows users to select moves and compete against a randomly generated
computer choice. The game logic follows standard rules, comparing choices to
determine the winner. Future enhancements can include animations, score
tracking, and multiplayer functionality for a better experience.
lambda → Used in command=lambda x=choice: self.play(x) for passing arguments to the function inside
a button click.
pack → Used for arranging buttons and labels in the Tkinter window (.pack(pady=10)).
random → Used for generating the computer's choice (random.choice([...])).
config → Used to update labels dynamically (self.result_label.config(text="...")).
tk → Tkinter module, used to create the GUI (import tkinter as tk).
title → Sets the window title (self.window.title("Rock Paper Scissors - 3 Rounds")).
geometry → Sets window size (self.window.geometry("300x300")).
window → Refers to the Tkinter window instance (self.window = tk.Tk()).
__init__ → Constructor method used to initialize class variables.
5. Actual Methodology Followed
Start
Create the main window using Tkinter and set the title and size.
Retrieve the "Rock", "Paper", and "Scissors" buttons using Tkinter’s Button widget.
Define a label to display instructions for the user.
Define an empty label (result_label) to display the game result.
Create an event listener for each button that triggers when clicked.
Inside the event:
o Get the player's choice from the clicked button.
o Generate the computer's choice randomly from the list: ['Rock', 'Paper',
'Scissors'].
o Compare the player's choice with the computer's choice:
If both choices are the same, display "It's a Tie!".
If the player wins based on game rules, display "You Win!".
Otherwise, display "Computer Wins!".
o Update the result_label to show the choices and the result.
Start the Tkinter main event loop to run the application.
End
6. Resources used
Sr.
Name of the resource/Material used Specification
No.
1. Laptop i9, 1TB,16 GB RAM
2. Software MS Word
Main.py
import random
import tkinter as tk
from tkinter import messagebox
def play_game(player_choice):
choices = ['Rock', 'Paper', 'Scissors']
computer = random.choice(choices)
if player_choice == computer:
result_text += "It's a Tie!"
elif ((player_choice == 'Rock' and computer == 'Scissors') or
(player_choice == 'Paper' and computer == 'Rock') or
(player_choice == 'Scissors' and computer == 'Paper')):
result_text += "You Win!"
else:
result_text += "Computer Wins!"
result_label.config(text=result_text)
window = tk.Tk()
window.title("Rock Paper Scissors")
window.geometry("300x250")
window.mainloop()
8. Output
9. Skill Developed:
Problem-Solving – Understanding game logic, implementing conditions, and
debugging.
GUI Development – Using Tkinter to create an interactive user interface.
Event Handling – Managing user inputs and updating the interface dynamically.
10. Conclusion
The Rock Paper Scissors game is a great beginner project for learning Python, GUI
design, and logic building. It improves problem-solving skills and provides an
interactive experience. The game can be expanded with more features like score tracking
and animations to make it even more engaging.