0% found this document useful (0 votes)
50 views

Shraddha

Pdf

Uploaded by

Shraddha Taware
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)
50 views

Shraddha

Pdf

Uploaded by

Shraddha Taware
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/ 29

AJEENKYA D. Y.

PATIL SCHOOL OF
ENGINEERING (POLYTECHNIC)

Department of Computer Engineering


2024-25 (5th Semester)

Report of
Industrial Training (ITR)
On

Python Development

Submitted by:
Roll no. Name of the Student Enrollment no.
82 Shraddha Taware 23213470414

Under the Guidance of


Mrs. Mayuri Narudkar
AJEENKYA DY PATIL SCHOOL OF ENGINEEERING
Department of Computer Engineering

SEMESTER - 5th ( 2024-25 )

CERTIFICATE

This is to certify that report entitled Python Development is submitted in the partial
fulfillment of requirement for the award of the Diploma in Computer Engineering by
Maharashtra State Board of Technical Education as record of student’s own work carried out
by them under the guidance and supervision at Ajeenkya DY Patil School Of Engineering,
during the academic year 2024-25.

Roll no. Name of the Student Enrollment no.


82 Shraddha Taware 23213470414

Place: Lohegaon
Date: / / 2024.

Mrs. Mayuri Narudkar Mrs. Nita Pawar


Guide Head of Computer Department
ACKNOWLEDGEMEMT

I would like to express my sincere gratitude to the PROAZURE SOFTWARE Solutions Pvt. Ltd.
for providing me with this incredible opportunity to learn and grow during my six-week internship. The
experience has been immensely valuable and enriching. First and foremost, I would like to thank my
mentors and instructors for their guidance and support throughout the internship. Their expertise and
willingness to help have been instrumental in my learning process. Their constructive feedback and
encouragement have motivated me to push my boundaries and achieve my goals.

I am deeply grateful to Mrs. Mayuri Narudkar for her subject matter expertise and her exceptional
teaching. Her insightful lectures and hands-on sessions have greatly enhancedmy understanding of data
science and machine learning concepts. Her support and encouragement have been invaluable
throughout this journey. I would also like to extend my heartfelt thanks to Mrs. Nita Pawar, Head of
the Department, for her leadership and vision. Her commitment to fostering a conducive learning
environment and ensuring the success of the internship program is highly appreciated.

I am also grateful to my fellow interns for creating a collaborative and supportive environment. Sharing
ideas, working on projects together, and learning from each other's experiences have greatly enhanced
my understanding of data science and machine learning. A special thank you to the administration and
technical support team for ensuring that all necessary resources and tools were available to us, making
the learning process smooth and efficient. This internship has provided me with astrong foundation in
data science and machine learning, and I am excited to build upon this knowledge in my future
endeavors. Thank you once again to everyone who has beena part of this journey.
INDUSTRIAL TRAINING
REPORT (ITR)

Python Development
1. Brief Introduction:

I recently completed a six-week full-time internship at the PROAZURE SOFTWARE


Solutions Pvt. Ltd., where I focused on Data Science and Machine Learning. Throughout
the internship, I gained hands-on experience in various aspects of these fields, including:

1. Python Programming: Developed a strong foundation in Python, which is


essential for data science and machine learning tasks.

2. Datasets: Learned how to handle and manipulate large datasets effectively.

3. Google Colab: Utilized Google Colab for coding and collaboration, making it
easier to share and execute code in the cloud.

4. NumPy and Pandas: Used these libraries for numerical computing and data
manipulation, respectively.

5. Matplotlib and Seaborn: Created visualizations to represent data and insights


clearly.

6. Scikit-Learn (SkLearn): Applied various machine learning algorithms and


techniques using this comprehensive library.

7. Keras: Implemented deep learning models with Keras, an open-source neural-


network library.
2. Aim of Industrial Training :

The aim of my internship at the PROAZURE SOFTWARE Solutions Pvt. Ltd. was to
develop a comprehensive understanding of data science and machine learning, along
with practical skills in relevant tools and technologies. Specifically, my goals were to:

1. Master Python Programming: Enhance my proficiency in Python, the primary


language for data science and machine learning.

2. Handle and Manipulate Data: Learn how to work with large datasets, including
cleaning, transforming, and analyzing data.

3. Utilize Data Science Tools: Gain hands-on experience with essential libraries
such as NumPy, Pandas, Matplotlib, Seaborn, and Scikit-Learn.

4. Develop Machine Learning Models: Understand and implement various


machine learning algorithms and techniques.

5. Explore Deep Learning: Gain insights into deep learning by working with
Keras and other neural network libraries.

6. Apply Knowledge to Projects: Complete practical projects to apply theoretical


concepts, solve real-world problems, and build a portfolio of work.

7. Collaborate and Share: Use platforms like Google Colab for coding,
collaboration, and sharing work with peers and mentors.
3. Key objectives of the Internship:

 Understand the program structure, goals, and available resources.

 Learn Python basics and develop basic scripting skills.

 Overview of essential data science libraries: NumPy, Pandas, Matplotlib,Seaborn.

 Understand and apply NumPy for numerical computing and array manipulation.

 Practice NumPy operations in Google Colab for collaborative coding.

 Explore advanced NumPy operations and applications in data manipulation.

 Learn to read and handle datasets using NumPy.

 Understand and apply Pandas for data manipulation and analysis.

 Practice data manipulation with Pandas in Google Colab.

 Explore data cleaning, transformation, and pre-processing with Pandas.

 Learn to read and manipulate datasets using Pandas.

 Apply NumPy for advanced data manipulation tasks.

 Apply Pandas for advanced data manipulation tasks.

 Work on practical projects to apply learned skills.

 Develop and demonstrate projects utilizing NumPy.

 Develop and demonstrate projects utilizing Pandas.


INDEX

SR.NO. CONTENT PAGE


NO.

WEEKLY DIARY
1

PROJECT ON ROCK PAPER AND SCISSOR


2

LIFE CYCLE OF PAYTHON DEVELOPMENT


3

PROJECT AIM
4

5 IMAGES USED
PROGRAM CODE
6

7 OUTPUT
8 PROGRAM EXPLANATION
Weekly Diary

Week 1

Sr.No Day Content (Organization Study)

1 Day-1 Introduction to Programming, Choosing Python, Setting up


Pythonenvironment, Python IDEs

Running simple python script for displaying “Welcome”


2 Day-2 message.

3 Day-3 Python Basic Syntax and Data Types

4 Day-4 Introduction of Operators in Python

Write a program using operators for:-


5 Day-5  Arithmetic operator
 Logical operator

6 Day-6 Python Conditional Statement and write a program for


conditional statement.
Week 2

Sr.No Day Content (PHP)


Python Looping Concept:
1 Day-7  For Loop
 While Loop
 Loop control statements (break, continue, pass)
Python List:
 Create list
2 Day-8  Access list
 Update list (Add item, Remove item)
 Delete list
Python Tuple:
 Create Tuple
3 Day-9  Access Tuple
 Update Tuple
 Delete Tuple
Python Dictionaries:
 Create Dictionary
Day-10  Access Dictionary elements
4  Update Dictionary
 Delete Set
 Logging through Dictionary
Python Sets:
 Create Set
5 Day-11  Access Set elements
 Update Set
 Delete Set

6 Day-12 Write a program on this basis of this Data structures


Week 3

Sr.No Day Content (PHP)

1 Day-13 Introduction of Python Functions, modules, and Packages

Write a program to Creating functions and Calling


2 Day-14 functions
User defined functions: Function definition, Function calling,
3 Day-15 function arguments and parameter passing, Return statement,
Scope of Variables: Global variableand Local Variable.

Modules: Writing modules, importing modules, importing


4 Day-16 objects from modules, Python built — in modules (e.g.
Numeric and mathematical module, Functional
Programming Module) Namespace and Scoping.
Python Packages: Introduction, Writing Python packages,
5 Day-17 Using standard (e.g. math, scipy, Numpy, matplotlib, pandas
etc.) and user defined packages

Develop user defined Python function for given problem:


6 Day-18  Function with minimum 2 arguments
 Function returning values
Week 4

Sr.No Day Content (PHP)

1 Day-19 Introduction of Object Oriented Programming in Python

 Creating Classes and Objects.


2 Day-20  Method Overloading and Overriding.

 Data Hiding.
3 Day-21  Data abstraction.

 Inheritance and composition classes


4 Day-22  Customization via inheritance specializing inheritedmethods

Introduction of Date Time Module:


 date module
5 Day-23  time module
 date-time module
 time delta

 formatting date and time


6 Day-24  strftime()
 striptime()
Week 5

Sr.No Day Content (PHP)

1 Day-25 Introduction of Email module in Python and write a program to


send a email.

2 Day-26 Introduction of File I/O Handling and Exception Handling

3 Day-27  Opening file


 Opening different file types

4 Day-28  Read, write, close files


 Opening files in different modes

5 Day-29 Exceptions and Error handling:


 Handling errors using try, except and finally.

6 Day-30 Live project Demonstration and Sample project development.


Week 6

Sr.No Day Content (Team Activities)

Sample Project Development on Studied Technologies withgroup


1 Day-31
members

2 Day-32 Importance of Software testing during the development

3 Day-33 Guidance of Special Expert for How to become a Successful


Software Developer in IT Forum

4 Day-34 Basics of Report Writing and Sample of writing Industrialtraining


report

5 Day-35 Team Activities, Leadership Activities

6 Day-36 Feedback and Validation


Conclusion:
The 6-week internship at the PROAZURE SOFTWARE Solutions Pvt. Ltd. was a trans-
formative experience, providing a comprehensive introduction to Data Science and Machine
Learning. Thisprogram was meticulously structured to build a strong foundation in Python
programming and essential libraries, followed by practical, hands-on projects that solidified
my understanding and skills.

I would like to extend my heartfelt thanks to my mentor, Mrs. Mayuri Narudkar, for her
invaluable guidance, patience, and support throughout the internship. Her insights and
encouragement greatly contributed to my learning and development. I am also grateful to
Mrs. Nita Pawar, Head of the Department, for providing this opportunity and supporting
my journey.

This internship has been an enriching experience, enhancing both my technical skillsand
confidence in applying data science techniques. The hands-on projects were particularly
beneficial, offering practical experience that reinforced the theoretical knowledge gained.
As I move forward, I am excited to continue exploring the vast field of data science and
machine learning, confident that the skills and knowledge acquired during this internship
will serve me well in my future academic and professional pursuits.

Mrs. Mayuri Narudkar


(Guide of the project)
PROJECT ON ROCK PAPER AND SCISSOR

Program Development Life Cycle (PDLC) – Software Engineering


The Program Development Life Cycle (PDLC) is a process used in software engineering to manage the
development of software programs. The PDLC is similar to the Software Development Life Cycle (SDLC)
but is applied at a higher level, to manage the development of multiple software programs or projects. This
article focuses on discussing PDLC in detail.

What is PDLC?
The PDLC is an iterative process that allows for feedback and adjustments to be made at each phase, to
ensure that the final product meets the needs of the stakeholders and is of high quality.

Program Development Life Cycle (PDLC) is a systematic way of developing quality software.
It provides an organized plan for breaking down the task of program development into manageable chunks,
each of which must be completed before moving on to the next phase.

Phases of PDLC
Planning: In this phase, the goals and objectives of the program are defined, and a plan is developed to
achieve them. This includes identifying the resources required and determining the budget and schedule for
the program.

Analysis: In this phase, the requirements for the program are defined and analyzed. This includes
identifying the stakeholders, their needs and expectations, and determining the functional and non-functional
requirements for the program.

Design: In this phase, the program’s architecture and design are developed. This includes creating a
detailed design of the program’s components and interfaces, as well as determining how the program will be
tested and deployed.

Implementation: In this phase, the program is developed and coded. This includes writing the program’s
source code and creating any necessary documentation.

Testing: In this phase, the program is tested to ensure that it meets the requirements and is free of defects.

Deployment: In this phase, the program is deployed and made available to users.

Maintenance: After the deployment, the program is maintained by fixing any bugs or errors that are found
and updating the program to meet changing requirements.

Steps in PDLC
The program development process is divided into the steps discussed below:

1. Defining the Problem


The first step is to define the problem. In major software projects, this is a job for system analyst, who
provides the results of their work to programmers in the form of a program specification. The program
specification defines the data used in program, the processing that should take place while finding a solution,
the format of the output and the user interface.

2. Designing the Program


Program design starts by focusing on the main goal that the program is trying to achieve and then breaking
the program into manageable components, each of which contributes to this goal. This approach of program
design is called top-bottom program design or modular programming. The first step involve identifying
main routine, which is the one of program’s major activity. From that point, programmers try to divide the
various components of the main routine into smaller parts called modules. For each module, programmer
draws a conceptual plan using an appropriate program design tool to visualize how the module will do its
assign job. Program Design Tools: The various program design tools are described below:

Structure Charts: A structure chart, also called Hierarchy chart, show top-down design of program. Each
box in the structure chart indicates a task that program must accomplish. The Top module, called the Main
module or Control module. For example: Structure Chart
Algorithms: An algorithm is a step-by-step description of how to arrive at a solution in the most easiest way.
Algorithms are not restricted to computer world only. In fact, we use them in everyday life.

Flowcharts: A flowchart is a diagram that shows the logic of the program. For example:Flowchart

Decision tables: A Decision table is a special kind of table, which is divided into four parts by a pair of
horizontal and vertical lines.

Pseudocode: A pseudocode is another tool to describe the way to arrive at a solution. They are different
from algorithm by the fact that they are expressed in program language like constructs.

3. Coding the Program


Coding the program means translating an algorithm into specific programming language. The technique of
programming using only well defined control structures is known as Structured programming. Programmer
must follow the language rules, violation of any rule causes error. These errors must be eliminated before
going to the next step.

4. Testing and Debugging the Program


After removal of syntax errors, the program will execute. However, the output of the program may not be
correct. This is because of logical error in the program. A logical error is a mistake that the programmer
made while designing the solution to a problem. So the programmer must find and correct logical errors by
carefully examining the program output using Test data. Syntax error and Logical error are collectively
known as Bugs. The process of identifying errors and eliminating them is known as Debugging.
5. Documenting the Program
After testing, the software project is almost complete. The structure charts, pseudocodes, flowcharts and
decision tables developed during the design phase become documentation for others who are associated with
the software project. This phase ends by writing a manual that provides an overview of the program’s
functionality, tutorials for the beginner, in-depth explanations of major program features, reference
documentation of all program commands and a thorough description of the error messages generated by the
program.

6. Deploying and Maintaining the Program


In the final phase, the program is deployed (installed) at the user’s site. Here also, the program is kept under
watch till the user gives a green signal to it. Even after the software is completed, it needs to be maintained
and evaluated regularly. In software maintenance, the programming team fixes program errors and updates
the software.

Benefits of PDLC
1.Provides a structured approach: PDLC provides a structured approach to developing software, which
helps to ensure that the program is developed in a logical and organized way.

2.Facilitates communication: PDLC helps to facilitate communication between different stakeholders, such
as developers, project managers, and customers.

3.Identifies and manages risks: PDLC helps to identify and manage potential risks during the development
of the program, allowing for proactive measures to be taken to mitigate them.

4.Improves quality: PDLC helps to improve the quality of the final product by providing a systematic
approach to testing and quality assurance.

5.Increases efficiency: By following a PDLC, the development process becomes more efficient as it allows
for better planning and organization.

Limitations of PDLC
1. Can be time-consuming: Following a strict PDLC can be time-consuming, and may delay the
development of the program.
.
2. Can be inflexible: The rigid structure of PDLC may not be suitable for all types of software
development projects, and may limit the ability to incorporate changes or new ideas.

3. Can be costly: Implementing a PDLC may require additional resources and budget, which can be
costly for organizations.

4. Can be complex: PDLC can be complex, and may require a certain level of expertise and knowledge
to implement effectively.

5. May not be suitable for smaller projects: PDLC may not be suitable for smaller projects as it can
be an overkill and would not be cost-effective.
Rock, Paper, Scissor game – Project

 Aim of the project


In this article, we will see how we can create a rock paper and scissor game using Tkinter. Rock paper
scissor is a hand game usually played between two people, in which each player simultaneously forms
one of the three shapes with an outstretched hand. These shapes are “rock”, “paper”, and “scissors”.

Game Winner Conditions

Let there be a Player who is playing with a computer as an opponent. Now,


• If the player selects Paper and Computer Selects Scissor – Computer wins
• If the player selects Rock and Computer Selects Scissor – Player 1 wins
• If the player selects Paper and Computer Selects Rock – Player 1 wins
• And If the player selects Paper and Computer Selects Paper – Draw
• If the player selects Rock and Computer Selects Rock – Draw
• If the player selects Scissor and Computer Selects Scissor – Draw

 Tools and Technologies Used

1. Tkinter: It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with
tkinter is the fastest and easiest way to create GUI applications.
2. Random: Python defines a set of functions that are used to generate or manipulate random
numbers through the random module.
3. PIL: Python Imaging Library (expansion of PIL) is the de facto image processing package for
Python language. It incorporates lightweight image processing tools that aids in editing, creating
and saving images.

 GUI Implementation

1: Image processing Part and handling


1) Import Python Module Tkinter to execute GUI applications.

2) From PIL Import ImageTk, Image for image processing.

3) Import random which will help the computer to select options rock, paper, or scissor randomly.

4) Now an object is created root which is the main window object.

Title of this window -> Rock Paper Scissor


Dimensions of this window -> “800×680”

5) Create canvas of width=800, height=680

6) Now we Create labels on GUI window

l1 =Player-> font=’Algerian’, size=25


l2 =Computer-> font=’Algerian’, size=25
l3 =Vs font=’Algerian’, size=40
7) Now labels are placed on window

l1 at x=80, y=20
l2 at x=560, y=20
l3 at x=370, y=230
For Default Image:

1) An variable named img_p is used to open the default hand image and resize it to (300,300). This will
be shown at default condition in the game at the place of the player.

2) An variable named img_c is used to store flipped default image from left to right using transpose
function and it is saved in the variable. This will be shown at default condition in the game at the place
of the computer’s side.

 For Rock Image:

1) An variable named rock_p is used to open the rock hand image and resize it to (300,300). This will be
shown at the player’s side when the player selects rock in the game.

2) An variable named rock_c is used to store flipped rock hand image from left to right using transpose
function and will be shown at computer’s side when the computer randomly selects rock in the game.

3) Images rock_p and rock_c are loaded on the canvas now using Tk.PhotoImage.

 For Paper Image

1) An variable named paper_p is used to open the paper hand image and resize it to (300,300). This will
be shown at the player’s side when the player selects paper in the game.

2) An variable named paper_c is used to store flipped paper hand images from left to right using the
transpose function and will be shown at the computer’s side when the computer randomly selects paper
in the game.

3) Images paper_p and paper_c is loaded on the canvas now using Tk.PhotoImage.

 For Scissors Image

1) An variable named scissor_p is used to open the scissor hand image and resize it to (300,300). This
will be shown at player’s side when player selects scissor in the game.

2) An variable named scissor_c is used to store flipped scissor hand image from left to right using
transpose function and will be shown at computer’s side when computer randomly selects scissor in the
game.

3) Images scissor_p and scissor_c are loaded on the canvas now using Tk.PhotoImage.
 For Selection Image:

1) An variable named img_s is used to open the selection of hand images i.e. Combined image of Rock,
Paper & Scissor, and resize it to (300,130).

3) Image img_s is loaded on the canvas now using Tk.PhotoImage.


4)

 Part 2: Game Implementation

1) A game function is defined in which we have a list named select having values 1, 2, 3
representing rock, paper, and scissors respectively.

2) Here random.choice randomly selects options 1-3 for computer

3) Set image for Player on canvas


• If Player selects 1 (Rock) Show rock image on canvas using create_image.
• If Player selects 2 (Paper) Show paper image on canvas using create_image.
• If Player selects 3 (Scissor) Show scissor image on canvas using create_image.

4) Set image for Computer on canvas


• If Computer selects 1 (Rock) Show rock image on canvas using create_image.
• If Computer selects 2 (Paper) Show paper image on canvas using create_image.
• If Computer selects 3 (Scissor) Show scissor image on canvas using create_image.

5) Obtaining the result


• If Player chooses Rock and computer chooses Rock OR If the player chooses Paper and the
computer chooses Paper OR If the player chooses Scissor and the computer chooses Scissor.
Result Shown-> Draw
• If the Player chooses Rock and computer choose Scissor OR If the player chooses Paper and
computer choose Rock OR If the player chooses Scissor and computer choose Paper. Result
Shown -> Player won
• Else Result Shown-> Computer won
• Note: This result is shown on canvas in form of text having dimensions (390,600),
font=’Algerian’, tag=’result’.

6) Buttons

• Clear Button -> Deletes the present result and switches the figures at both sides to its default
conditions.
• Rock Button -> Selects choice 1 in function game and Shows an Image of Hand showing Rock
On Player side.
• Paper Button -> Selects choice 2 in function game and Shows Image of Hand showing Paper On
Player side
• Scissor Button -> Selects choice 3 in function game and Shows an Image of Hand showing the
Scissor On the Player side.
Images Used:

paper Rock

scissor
PROGRAM C0DE:

from tkinter import *


from PIL import ImageTk, Image
import random

# main window object


root = Tk()

# Title of GUI window


root.title('Rock Paper Scissor')

# Size of window
root.geometry('800x680')

# Creating canvas
canvas = Canvas(root, width=800, height=680)
canvas.grid(row=0, column=0)

# Creating labels on GUI window


l1 = Label(root, text='Player', font=('Algerian', 25))
l2 = Label(root, text='Computer', font=('Algerian', 25))
l3 = Label(root, text='Vs', font=('Algerian', 40))

# Placing all the labels on window


l1.place(x=80, y=20)
l2.place(x=560, y=20)
l3.place(x=370, y=230)

# Default image
img_p = Image.open("default.jpeg")
img_p = img_p.resize((300, 300))

# Flipping image from left to right


img_c = img_p.transpose(Image.FLIP_LEFT_RIGHT)

# Loading images to put on canvas


img_p = ImageTk.PhotoImage(img_p)
img_c = ImageTk.PhotoImage(img_c)

# Rock image
rock_p = Image.open('rock.jpeg')
rock_p = rock_p.resize((300, 300))

# Flipping image from left to right


rock_c = rock_p.transpose(Image.FLIP_LEFT_RIGHT)

# Loading images to put on canvas


rock_p = ImageTk.PhotoImage(rock_p)
rock_c = ImageTk.PhotoImage(rock_c)
# Paper image
paper_p = Image.open('paper.jpeg')
paper_p = paper_p.resize((300, 300))

# Flipping image from left to right


paper_c = paper_p.transpose(Image.FLIP_LEFT_RIGHT)

# Loading images to put on canvas


paper_p = ImageTk.PhotoImage(paper_p)
paper_c = ImageTk.PhotoImage(paper_c)

# Scissor image
scissor_p = Image.open('scissor.jpeg')
scissor_p = scissor_p.resize((300, 300))

# Flipping image from left to right


scissor_c = scissor_p.transpose(Image.FLIP_LEFT_RIGHT)

# Loading images to put on canvas


scissor_p = ImageTk.PhotoImage(scissor_p)
scissor_c = ImageTk.PhotoImage(scissor_c)

# Selection image
img_s = Image.open("Selection.jpeg")
img_s = img_s.resize((300, 130))
img_s = ImageTk.PhotoImage(img_s)

# Putting image on canvas on specific coordinates


canvas.create_image(0, 100, anchor=NW, image=img_p)
canvas.create_image(500, 100, anchor=NW, image=img_c)
canvas.create_image(0, 400, anchor=NW, image=img_s)
canvas.create_image(500, 400, anchor=NW, image=img_s)

# game function
def game(player):
select = [1, 2, 3]

# Randomly selects option for computer


computer = random.choice(select)

# Setting image for player on canvas


if player == 1:

# Puts rock image on canvas


canvas.create_image(0, 100, anchor=NW, image=rock_p)
elif player == 2:

# Puts paper image on canvas


canvas.create_image(0, 100, anchor=NW, image=paper_p)
else:

# Puts scissor image on canvas


canvas.create_image(0, 100, anchor=NW, image=scissor_p)
# Setting image for computer on canvas
if computer == 1:

# Puts rock image on canvas


canvas.create_image(500, 100, anchor=NW, image=rock_c)
elif computer == 2:

# Puts paper image on canvas


canvas.create_image(500, 100, anchor=NW, image=paper_c)
else:

# Puts scissor image on canvas


canvas.create_image(500, 100, anchor=NW, image=scissor_c)

# Obtaining result by comparison


if player == computer: # Case of DRAW
res = 'Draw'

# Case of player's win


elif (player == 1 and computer == 3) or (player == 2 and computer == 1) or (player == 3 and
computer == 2):
res = 'You won'

# Case of computer's win


else:
res = 'Computer won'

# Putting result on canvas


canvas.create_text(390, 600, text='Result:- ' + res,
fill="black", font=('Algerian', 25), tag='result')

# Function for clear button


def clear():

# Removes result from canvas


canvas.delete('result')

# Puts default image on canvas


canvas.create_image(0, 100, anchor=NW, image=img_p)
canvas.create_image(500, 100, anchor=NW, image=img_c)

# Button for selecting rock


rock_b = Button(root, text='Rock', command=lambda: game(1))
rock_b.place(x=35, y=487)

# Button for selecting paper


paper_b = Button(root, text='Paper', command=lambda: game(2))
paper_b.place(x=128, y=487)

# Button for selecting scissor


scissor_b = Button(root, text='Scissor', command=lambda: game(3))
scissor_b.place(x=220, y=487)

# Button for clear


clear_b = Button(root, text='CLEAR', font=('Times', 10, 'bold'),
width=10, command=clear).place(x=370, y=28)

root.mainloop()

OUTPUT:
 Code Explanation:
1. The code starts by creating a window object called root.
2. The window has a title, which is “Rock Paper Scissor”.
3. The size of the window is set to 800×680 pixels.
4. Next, a canvas object is created.
5. The canvas has the same width and height as the window.
6. The grid command is used to create a grid on the canvas.
7. This will help us keep our drawings organized and easy to read.
8. The labels are then created using the text command.
9. Two labels are created – one for rock and one for paper.
10. These labels will be used in our game later on.
11. Finally, images are loaded into the canvas using the ImageTk library.
12. A random image is loaded for each player in our game (rock, paper, scissors).
13. The code creates a window and sets its title.
14. The window’s size is then set to 800×680 pixels.
15. Next, a canvas object is created and its grid attribute is set to row=0, column=0.
16. Finally, two labels are created and placed on the GUI window.
17. The code starts by creating three labels – Player, Computer, and Vs.
18. The first two labels are placed at the top-left corner of the window, while the third label is placed in
the middle of the window.
19. Next, the code sets up some variables to store information about each label.
20. l1 and l2 are assigned a Label object with the name ‘Player’ and ‘Computer’, respectively.
21. l3 is assigned a Label object with the name ‘Vs’.
22. The next line creates an Image object named img_p and saves it to disk as a JPEG file.
23. The image size is set to 300×300 pixels.
24. Finally, img_p is initialized as an Image object.
25. The code creates three labels on the window, Player, Computer, and Vs.
26. The first label, l1, is placed at the top-left corner of the window and has a text of “Player” assigned to
it.
27. The second label, l2, is placed in the middle of the window and has a text of “Computer” assigned to
it.
28. The last label, l3, is placed at the bottom-right corner of the window and has a text of “Vs” assigned
to it.
29. Next, the code opens an image named default.jpeg in Image object and sets its size to 300×300 pixels.
30. Finally, the code assigns this image as the default image for all three labels.
31. The code starts by loading the three images that will be used in the example.
32. The first image is a rock, the second is a paper, and the third is a selection image.
33. Next, the code flips each of these images so that they are displayed in reverse order.
34. This is done using the transpose() function.
35. The final step is to load each of these flipped images into an ImageTk PhotoImage object.
36. This allows us to display them onscreen together as one unit.
37. The code will first load the images “rock.jpeg”, “paper.jpeg”, and “scissor.jpeg” into the variables
img_p, img_c, and scissor_p, respectively.
38. Next, the code will transpose each image’s left to right (LTR) direction so that they will be displayed
on the canvas in their original orientation (RTL).
39. Finally, the code will create a new PhotoImage object for each image and assign it to the respective
variables img_s and img_c.
40. The code first creates three images on the canvas.
41. The first image is at coordinates (0, 100), the second image is at coordinates (500, 100), and the third
image is at coordinates (0, 400).
42. Next, the code defines a game function that will be used to control the player.
43. This game function takes one parameter – a player object – which represents a person in the game
world.
44. The game function first checks to see if the player has moved within its bounds.
45. If not, it returns immediately.
46. Otherwise, it sets up two variables – x and y – to represent where on the screen the player currently
is.
47. It then calls another function called draw() which will be used to draw all of the graphics in this
game.
48. The draw() function first sets up an anchor point for each of its three images using create_anchor().
49. Next, it draws each of those images using create_image().
50. Finally, it assigns these values back to their respective variables so that they can be used by other
parts of this program later on.

Subject Teacher
Mrs. MAYURI NARUDKAR

You might also like