Python Programming
Python Programming
Group of Institutions
(Polytechnic)
Topic Name
Certificate
This is to certify that Mr. Sahil Pritam Shaha Roll No: 24
of Sixth Semester of Diploma Programming in Engineering
& Technology at 1515–NIT Polytechnic Pune, has completed
the Micro Project satisfactorily in Subject Python Programming
[22616] in the academic year 2024-2025 as per the MSBTE
prescribed curriculum of I Scheme.
Seal Of
Institue
Index..
1 Introduction
2 Objectives (Cos)
o Game development
5. Extensive Libraries and Frameworks: Python has a rich
ecosystem of libraries and frameworks that simplify
development.
2. Interpreted Language:
Python code is executed line-by-line, which allows
for quick testing and debugging.
3. Dynamically Typed:
You don’t need to specify variable types explicitly;
Python determines them at runtime.
5. Cross-Platform:
Python is compatible with major operating systems
like Windows, macOS, and Linux, ensuring
portability.
6. Object-Oriented and Procedural:
Python supports multiple programming paradigms,
including object-oriented, procedural, and
functional programming.
7. Garbage Collection:
Python has automatic memory management,
freeing unused memory to optimize performance.
8. Open Source:
Python is freely available for use and modification,
backed by a large developer community.
9. Third-Party Libraries:
Python’s ecosystem includes powerful third-party
libraries like NumPy, Pandas, TensorFlow, and
Flask, enabling development across various
domains.
Advantages of Python:
2. Versatility:
Python is used in diverse fields, including web
development, data science, artificial intelligence,
machine learning, automation, and game
development.
3. Rapid Development:
Python’s concise syntax reduces development time
and improves productivity.
4. Community Support:
Python has a vast and active community, which
provides abundant resources, tutorials, and third-
party tools.
5. Integration Capabilities:
Python can easily integrate with other languages
and technologies like C, C++, Java, and .NET.
6. Scalability:
Python can handle large-scale applications,
making it suitable for enterprise-level software.
7. Rich Libraries and Frameworks:
Libraries like Django and Flask for web
development or Scikit-learn and TensorFlow for
AI and machine learning save time and effort.
8. Portability:
Python code written on one platform can run on
another without modification, provided necessary
dependencies are present.
9. Automation:
Python simplifies scripting and automating
repetitive tasks, making it popular among system
administrators.
10. Cost-Effective:
Being open-source and free, Python reduces
software development costs.
Algorithm Steps :
1. Start the program.
2. Display a welcome message: "Welcome to Stone, Paper,
Scissors Game!"
3. Set rounds = 1 to start the first round.
4. Loop (until the user decides to exit):
5. Display the current round number.
6. Prompt Player 1 to choose 1 for Stone, 2 for Paper, or 3 for
Scissors.
7. Prompt Player 2 to choose 1 for Stone, 2 for Paper, or 3 for
Scissors.
8. Validate the inputs:
a. If either player inputs a number other than 1, 2, or 3,
display an error message and continue to the next iteration.
9. Convert the numeric choice to the corresponding string
("Stone", "Paper", or "Scissor") using the get_choice() function.
10. Display the choices of both players (e.g., "Player 1 chose:
Stone").
11. Determine the winner using the determine_winner()
function:
a. If both players choose the same option, print "Match
Draw!".
b. If Player 1 wins based on the rules, print "Player 1 Wins!".
c. If Player 2 wins based on the rules, print "Player 2 Wins!".
12. Ask if both players want to play another round.
a. If the answer is "no", exit the loop and print "Thanks for
playing!".
b. If the answer is "yes", increment the round and continue to
the next round.
13. End the program.
Program :
import random
def get_choice(choice):
if choice == 1:
return "Stone"
elif choice == 2:
return "Paper"
elif choice == 3:
return "Scissor"
while True:
print(f"\nRound {rounds}")
try:
player1_choice = int(input("Player 1, select: 1 for
Stone, 2 for Paper, 3 for Scissors: "))
player2_choice = int(input("Player 2, select: 1 for
Stone, 2 for Paper, 3 for Scissors: "))
# Validate input
if player1_choice not in [1, 2, 3] or player2_choice not
in [1, 2, 3]:
print("\nInvalid input! Please choose 1, 2, or 3.")
continue
player1 = get_choice(player1_choice)
player2 = get_choice(player2_choice)
result = determine_winner(player1_choice,
player2_choice)
print(result)
rounds += 1
except ValueError:
print("\nInvalid input! Please enter a number.")
Program Output :
Explanation Of Program :
1. Imports:
o The random module is imported, but not used in this
version.
2. get_choice(choice):
o Converts a player's numeric input (1, 2, or 3) to a
3. determine_winner(player1, player2):
o Decides the winner based on the rules of the game:
draw.
If Player 1 beats Player 2's choice, Player 1
wins.
Otherwise, Player 2 wins.
Paper, or Scissors.
o Validates input to ensure it's 1, 2, or 3.
the winner.
o Asks if the players want to play another round.
5. Exit:
o The game continues until the player chooses not to
play again.
We Successfully Created
Stone Papper Scissor Game
Created By :
Sahil Pritam Shaha
TYCO - A
Roll No - 24