Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 33

PROFESSIONAL TRAINING REPORT

At

COMPUTER SOFTWARE COLLEGE

Submitted in partial fulfillment of the requirements for the award of

Bachelor of Engineering In

Electrical and Electronics Engineering

By

ARAVIND.K

REG NO : MJ1540

DEPARTMENT OF

ELECTRICAL AND ELECTRONICS ENGINEERING

COMPUTER SOFTWARE COLLEGE IN

MINJUR – 601 203

MARCH – 2024
COMPUTER SOFTWARE COLLEGE IN

MINJUR – 601 203

DEPARTMENT OF ELECTRICAL AND ELECTRONICS

ENGINEERING

BONAFIDE CERTIFICATE

This is to certify that this Project Report is the bonafide work of ARAVIND.K
(Reg. No: MJ1540) who carried out the project entitled “HANGMAN” Tool
using Python Program” under my supervision from Feb 2024 to March 2024.

SUBMITTED FOR THIS PROJECT WORK HELD IN

YEAR 23/12/2023-23/ 02/2024

GUIDANCE

CENTER HEAD

DATE

COMPUTER SOFTWARE

COLLEGE

#436, PRABHU COMPLEX

II FLOOR T.H ROAD

MINJUR – 601 203


ACKNOWLEDGEMENT
Thank you to our mentors and instructors for their guidance and feedback,
which helped shape this project. Finally, we are grateful to all the users who
provided feedback and helped us improve the Hangman game.

This project wouldn't have been possible without the collective effort and
collaboration of everyone involved.

Feel free to customize it with the specific names and details relevant to your
project!

Lastly, we acknowledge the numerous online resources, tutorials, and libraries


in the Python ecosystem that facilitated our learning journey and enabled us to
create this Hangman game.

This project stands as a testament to the collaborative spirit of the Python


community and the passion for creating engaging and educational software.

INSTITUTION:

I THANK MR.E.BOOPATHY OUR CENTER MANAGER AND ALSO.

I THANK MS.K.JAAHNAVI FOR THIS INVALUABLE GUIDANCE IN


THIS ENDEAVOUR.

I ALSO THANK STAFFS FOR THEIR GUIDANCE.


TABLE OF CONTENT

TOPIC’S

1. INTRODUCTION

1.1 HISTROY OF PYTHON

1.2 APPLICATION OF PYTHON

1.3 FEATURES IN PYTHON

2.CURRENT APPLICATION OF PYTHON

2.1 ADVANTAGES

2.2 APPLICATIONS

2.3 ORGANIZATION USING OF PYTHON

3.TKINTER

3.1 INTRODUCTION OF TKINTER

3.2 FUNDAMENTAL STRUCTURE OF TKINTER PROGRAM

3.3 USES OF TKINTER

4.MINI PROJECT

4.1 ABSTRUCT

4.2 ALGORITHM

4.3 SOURCE CODE

4.4 OUTPUT
4.5 RULES OF THE GAME

4.6 FUTURE ENHANCEMENT

4.7 FLOW CHART

4.8 CONCLUSTION

4.9 REFFERENCES

PYTHON
1.INTRODUCTION

1.1 HISTROY OF PYTHON

Python is a widely used general-purpose, high-level programming language. It


was initially designed by Guido van Rossum in 1991 and developed by
Python Software Foundation. It was mainly developed for emphasis on code
readability, and its syntax allows programmers to express concepts in fewer
lines of code.

Who invented Python?

In the late 1980s, history was about to be written. It was that time when
working on Python started. Soon after that, Guido Van Rossum began doing
its application-based work in December of 1989 at Centrum Wiskunde &
Informatica (CWI) which is situated in the Netherlands. It was started as a
hobby project because he was looking for an interesting project to keep him
occupied during Christmas.
The programming language in which Python is said to have succeeded is ABC
Programming Language, which had interfacing with the Amoeba Operating
System and had the feature of exception handling. He had already helped
create ABC earlier in his career and had seen some issues with ABC but liked
most of the features. After that what he did was very clever. He had taken the
syntax of ABC, and some of its good features. It came with a lot of
complaints too, so he fixed those issues completely and created a good
scripting language that had removed all the flaws. The inspiration for the
name came from the BBC’s TV Show – ‘Monty Python’s Flying Circus’, as
he was a big fan of the TV show and also he wanted a short, unique and
slightly mysterious name for his invention and hence he named it Python! He
was the “Benevolent dictator for life” (BDFL) until he stepped down from the
position as the leader on 12th July 2018. For quite some time he used to work
for Google, but currently, he is working at Dropbox
1.2 Applications of Python

a. Web Development:

Python is widely used in web development. It makes use of simple code to build
a beautiful and functional website. It has related libraries and modules like
HTTP, XML, JSON, IMAP, POP, FTP, etc. These help in storage in databases,
content management, and interfacing with internet protocols.

It also has frameworks integrated with it like Django, Flask, Pyramid, and
Bottle. In addition, Python also comes with packages like Beautiful Soup,
Twisted Python, and Feedparser.

b. Artificial Intelligence and Machine Learning:


Many AI and ML models are built using Python. Data analysts use it too. The
fundamental cause for this is the availability of many tools and libraries specific
to these applications. Some of them include:

 Pandas for Data Manipulation and Analysis.


 NumPy and SciPy for mathematical computations.
 Seaborn and Matplotlib for visualization.

c. Game Development:
One of the interesting applications of the Python Programming language is to
build games like egg catcher, snake game, etc.

Python comes with packages like Pygame and Pykyra to build awesome games.
It facilitates the development of 3D games with respective libraries. It is also
used for scripting in many game engines.

Famous games like Battlefield 2, World of Tanks, Toontown Online, and


Civilization 4 are also built using Python.

d. Desktop GUI Development:

Its simplicity and platform independence nature make it a good choice for GUI
applications. Though Tkinter is the standard library for GUI development, there
are other supporting libraries like:

 Wx Python
 Kivy,PyQt, PySide
e. Enterprise/ Business Applications:

Business applications are developed keeping in mind the comfort and ease of
usage by the organization. Python’s features like scalability, extensibility, and
readability make it the best choice for business applications.

The following used Python:

 Odoo: This is an all-in-one business management software for enterprising


purposes.
 Tryton: general-purpose, high level, third-tier business application

f. Software Development:
Python supports the development of software with its libraries and packages. It
is used for building, testing, management, and so on. For example

 Scons help in build control


 Buildbot and Apache are used for autonomous and continuous testing.
 Roundup and Trac test and manage errors.

g. Educational Purposes:
Python helps beginners get introduced to the Programming environment. It is
because of its simple syntax and beginner-friendly nature. Another reason could
be its scope and reach in the development community.

h. Operating Systems Development:


Many operating systems are using Python as a backbone. Generally, it is used
along with C. Some of them are as follows:

 Linux based Ubuntu’s Ubiquity Installer


 Anaconda Installer of Red Hat Enterprises
1.3. Features in Python

In this section we will see what are the features of Python programming
language:

a. Free and Open Source:

Python language is freely available at the official website and you can
download it from the given download link below click on the Download
Python keyword. Download Python Since it is open-source, this means that
source code is also available to the public. So you can download it, use it as
well as share it.

b. Easy to code:

Python is a high-level programming language . Python is very easy to learn the


language as compared to other languages like C, C#, Javascript, Java, etc. It is
very easy to code in the Python language and anybody can learn Python
basics in a few hours or days. It is also a developer-friendly language.

c. Easy to Read:

As you will see, learning Python is quite simple. As was already established,
Python’s syntax is really straightforward. The code block is defined by the
indentations rather than by semicolons or brackets.

d. Object-Oriented Language:

One of the key features of Python is Object-Oriented programming . Python


supports object-oriented language and concepts of classes, object
encapsulation, etc.

e. GUI Programming Support:

Graphical User interfaces can be made using a module such as PyQt5, PyQt4,
wxPython, or Tk in Python. PyQt5 is the most popular option for creating
graphical apps with Python.
f. High-Level Language:

Python is a high-level language. When we write programs in Python, we do


not need to remember the system architecture, nor do we need to manage the
memory.

g. Large Community Support:

Python has gained popularity over the years. Our questions are constantly
answered by the enormous Stack Overflow community. These websites have
already provided answers to many questions about Python, so Python users
can consult them as needed.

h. Easy to Debug:

Excellent information for mistake tracing. You will be able to quickly identify
and correct the majority of your program’s issues once you understand how
to interpret Python’s error traces. Simply by glancing at the code, you can
determine what it is designed to perform.

i. Python is a Portable language:

Python language is also a portable language. For example, if we have Python


code for Windows and if we want to run this code on other platforms such
as Linux, Unix, and Mac then we do not need to change it, we can run this
code on any platform.

j. Python is an Integrated language:

Python is also an Integrated language because we can easily integrate Python


with other languages like C, C++, etc.
2. CURRENT APPLICATION OF PYTHON

Python is most commonly used in website development, software development,


task automation, data analysis and data visualization. Python is an incredibly
versatile programming language.

2.1 ADVANTAGES

 Presence of third-party modules: Python has a rich ecosystem of third-


party modules and libraries that extend its functionality for various tasks.

 Extensive support libraries: Python boasts extensive support libraries


like NumPy for numerical calculations and Pandas for data analytics,
making it suitable for scientific and data-related applications.

 Open source and large active community base: Python is open source,
and it has a large and active community that contributes to its development
and provides support.

 Versatile, easy to read, learn, and write: Python is known for its
simplicity and readability, making it an excellent choice for both
beginners and experienced programmers.

 User-friendly data structures: Python offers intuitive and easy-to-use


data structures, simplifying data manipulation and management.

 High-level language: Python is a high-level language that abstracts low-


level details, making it more user-friendly.

 Dynamically typed language: Python is dynamically typed, meaning you


don’t need to declare data types explicitly, making it flexible but still
reliable.

 Object-Oriented and Procedural programming language: Python


supports both object-oriented and procedural programming, providing
versatility in coding styles.

 Portable and interactive: Python is portable across operating systems


and interactive, allowing real-time code execution and testing.
 Ideal for prototypes: Python’s concise syntax allows developers to
prototype applications quickly with less code.

 Highly efficient: Python’s clean design provides enhanced process


control, and it has excellent text processing capabilities, making it
efficient for various applications.

 Internet of Things (IoT) opportunities: Python is used in IoT


applications due to its simplicity and versatility.

 Interpreted language: Python is interpreted, which allows for easier


debugging and code development.

2.2 APPLICATION

 GUI-based desktop applications: Python is used to develop graphical


user interface (GUI) applications.

 Graphic design, image processing, games, and


scientific/computational applications: Python is employed in graphics,
games, and scientific computing.

 Web frameworks and applications: Popular web frameworks


like Django and Flask are built using Python.

 Enterprise and business applications: Python is used for various


business applications, including data analysis and automation.

 Operating systems: Python is used in the development of operating


systems and system tools.

 Education: Python is commonly used for teaching programming and


computer science.

 Database access: Python provides libraries for accessing and managing


databases.
 Language development: Python is used to create and develop new
programming languages.

 Prototyping: Python is ideal for quickly prototyping software and


applications.

 Software development: Python is used for general-purpose software


development.

 Data science and machine learning: Python is a primary language for


data science and machine learning tasks.

 Scripting: Python is widely used for writing scripts to automate tasks and
processes.

2.3 ORGANIZATIONS OF USING PYTHON

As this is a site devoted to Python, we’ve already told you why Python is a great
language to learn
3. TKINTER

3.1 INTRODUCTION OF TKINTER

Graphical User Interface (GUI) :

A form of user interface which allows users to interact with computers through
visual indicators using items such as icons, menus, windows, etc. It has
advantages over the Command Line Interface (CLI) where users interact with
computers by writing commands using keyboard only and whose usage is
more difficult than GUI.

What is Tkinter?

Tkinter is the inbuilt python module that is used to create GUI applications. It
is one of the most commonly used modules for creating GUI applications in
Python as it is simple and easy to work with. You don’t need to worry about
the installation of the Tkinter module separately as it comes with Python
already. It gives an object-oriented interface to the Tk GUI toolkit.
Some other Python Libraries available for creating our own GUI applications
are
 Kivy
 Python Qt
 wxPython

What are Widgets?

Widgets in Tkinter are the elements of GUI application which provides various
controls (such as Labels, Buttons, ComboBoxes, CheckBoxes, MenuBars,
Radio Buttons and many more) to users to interact with the application.
3.2 FUNDAMENTAL STRUCTURE OF TKINTER PROGRAM

EXAMPLE CODE FOR TKINTER:

from tkinter import *

root = Tk()

T = Text(root, height=2, width=30)

T.pack()

T.insert(END, 'GeeksforGeeks\nBEST WEBSITE\n')


mainloop()
OUTPUT:

USES OF TKINTER:

Python offers multiple options for developing GUI (Graphical User Interface).
Out of all the GUI methods, tkinter is the most commonly used method. It is a
standard Python interface to the Tk GUI toolkit shipped with Python. Python
tkinter is the fastest and easiest way to create GUI applications. Creating a
GUI using tkinter is an easy task .

To create a tkinter Python app:

 Importing the module – tkinter


 Create the main window (container)
 Add any number of widgets to the main window
 Apply the event Trigger on the widgets.
PROJECT TITLE:

“HANGMAN”
4. MINI PROJECT

4.1 ABSTRUCT:

 Initialization:

o Begin by importing necessary modules like random for word


selection.
o Define a list of words or phrases from which the secret word will
be chosen.
o Set up the initial state of the hangman display and the blank
spaces representing the letters in the word to be guessed.
o Determine the maximum number of incorrect guesses allowed
before the game ends.

 Selecting a Word:

o Randomly select a word or phrase from the predefined list to


serve as the secret word that the player must guess.

 Displaying the Word:

o Display the secret word as a series of underscores representing


each letter.
o Maintain a list to track correctly guessed letters and display them
in their corresponding positions in the word.

 User Input:

o Prompt the player to guess a letter.


o Validate the input to ensure it's a single letter and hasn't been
guessed before.

 Checking the Guess:

o Compare the guessed letter with the letters in the secret word.
o If the letter is correct, reveal its positions in the word and update
the display.
o If the letter is incorrect, increment the count of incorrect guesses
and possibly update the hangman display.

 Game Progression:

o Continuously prompt the player for guesses until they either


correctly guess the word, run out of guesses, or choose to quit.
o Display appropriate messages based on the outcome (win, lose, or
quit).

 End Game:

o Display the full word if the player loses.


o Ask the player if they want to play again.

4.2 ALGORITHM

 We can assume the word is drawn from a particular dictionary

 We know the number of letters in the word

 Eliminate all words in the dictionary that do not have the correct number
of letters.

 Choose the not-yet-guessed letter which occurs in the largest number of


words in the remaining subset of the dictionary.

 If this letter occurs, we know its location.

 If this letter does not occur, we know it does not occur in the word.

 Eliminate all words in the dictionary subset that do not fit exactly this
correct pattern, and repeat.
 If there are 2 (or more) letters appearing equally often, the algorithm may
perform a deeper analysis of the positions to determine which one is
preferred (if that is reasonable?
4.3 SOURCE CODE:

from tkinter import *


from tkinter import messagebox
from string import ascii_uppercase
import random

window = Tk()
window.title('Hangman-GUESS GAMES NAME')
word_list=
['CRICKET' ,'HOCKEY' ,'BATMINTON','FOOTBALL' ,'TENNIS' ,'BASKET
BALL']
photos = [PhotoImage(file="images/hang0.png"),
PhotoImage(file="images/hang1.png"), PhotoImage(file="images/hang2.png"),
PhotoImage(file="images/hang3.png"), PhotoImage(file="images/hang4.png"),
PhotoImage(file="images/hang5.png"),
PhotoImage(file="images/hang6.png"), PhotoImage(file="images/hang7.png"),
PhotoImage(file="images/hang8.png"),
PhotoImage(file="images/hang9.png"),
PhotoImage(file="images/hang10.png"),
PhotoImage(file="images/hang11.png")]

def newGame():
global the_word_withSpaces
global numberOfGuesses
numberOfGuesses =0

the_word=random.choice(word_list)
the_word_withSpaces = " ".join(the_word)
lblWord.set(' '.join("_"*len(the_word)))

def guess(letter):
global numberOfGuesses
if numberOfGuesses<11:
txt = list(the_word_withSpaces)
guessed = list(lblWord.get())
if the_word_withSpaces.count(letter)>0:
for c in range(len(txt)):
if txt[c]==letter:
guessed[c]=letter
lblWord.set("".join(guessed))
if lblWord.get()==the_word_withSpaces:
messagebox.showinfo("Hangman","You
guessed it!")
else:
numberOfGuesses += 1
imgLabel.config(image=photos[numberOfGuesses])
if numberOfGuesses==11:
messagebox.showwarning("Hangman","Game
Over")

imgLabel=Label(window)
imgLabel.grid(row=0, column=0, columnspan=3, padx=10, pady=40)

lblWord = StringVar()
Label(window, textvariable =lblWord,font=('consolas 24 bold')).grid(row=0,
column=3 ,columnspan=6,padx=10)

n=0
for c in ascii_uppercase:
Button(window, text=c, command=lambda c=c: guess(c),bg = "blue" , fg =
'white' ,font=('Helvetica 18'), width=4).grid(row=1+n//9,column=n%9)
n+=1

Button(window, text="New\nGame", command=lambda:newGame(), bg =


"yellow" , font=("Helvetica 10 bold")).grid(row=3, column=8)

newGame()
window.mainloop()
4.4 OUTPUT:
4.5 RULES OF THE GAME:

In order to integrate this game into a code-based solution, we must first


comprehend the game's rules—how does it operate? Only then will we be able
to effectively convert to code.

 A word or a collection of words is chosen by an individual.


 A player makes an educated estimate as to which letter may begin or end
the word or list of words.
 If the letter appears in the word/list of words, the player receives a point
and is given another chance to predict a letter.
 If the letter isn't in the word, the player loses a try (tries)/point and a piece
of the hangman emerges.
 The hangman emerges in bits and pieces for each incorrectly guessed
letter until the whole picture is created.
 Similarly, the letters are put on the screen for each correctly predicted
letter until the word is finished and the player wins.

4.6 FUTURE ENHANCEMENT:

There are several ways to enhance the Hangman game to make it more
engaging and enjoyable for players. Here are some ideas for future
enhancements:

Difficulty Levels: Implement different difficulty levels with varying word


lengths or limited attempts based on the player's preference or skill level.

Category Selection: Allow players to choose from different word categories


(e.g., animals, countries, movies) to add variety and customization to the game.

Visual Enhancements: Improve the visual presentation of the game with


graphics, animations, or a graphical user interface (GUI) to enhance the player
experience.
Hint System: Add a hint system that provides clues about the hidden word,
such as its category or the first letter, to assist players who may be struggling.

Multiplayer Mode: Enable multiplayer functionality, allowing players to


compete against each other or collaborate in guessing the word.

Scorekeeping: Implement a scoring system to track players' performance over


multiple rounds and encourage replayability.

Word Database: Expand the word database to include a wider range of words
and phrases, or integrate with online APIs to fetch real-time data for an endless
supply of words.

Custom Word Input: Allow players to input their own words or phrases,
making the game more personalized and interactive.

Sound Effects and Music: Incorporate sound effects and background music to
enhance the atmosphere and immersion of the game.

Achievements and Rewards: Introduce achievements, challenges, or rewards


for completing certain milestones or achieving high scores, providing additional
motivation for players.

Mobile Compatibility: Optimize the game for mobile devices, making it


accessible to a broader audience and allowing players to enjoy the game on the
go.

Social Features: Integrate social features such as leader boards, sharing


options, or multiplayer challenges to foster a sense of community and
competition among players.

.
4.7 FLOW CHART:
|

 Start Game: The game begins.


 Choose Random Word: A word is selected randomly from a predefined
list.

 Display Initial Word: The initial display of the word is shown with
underscores for each letter.

 Guess a Letter: The player guesses a letter.

 Letter in Word?: Checks if the guessed letter is in the word.

 Yes: Updates the guessed letters display and checks if the word has been
fully guessed.

 No: Increments the number of attempts and checks if the player has run
out of attempts.

 Display Updated Word: Shows the updated word with guessed letters
revealed.

 All Letters Guessed?: Checks if all letters in the word have been
guessed.

 Yes: Player wins.

 No: Player runs out of attempts and loses.

SEQUENCE DIAGRAM:
CLASS DIAGRAM:
4.8 CONCULSION:
Certainly! The conclusion for a Hangman game typically involves informing the
player whether they have won or lost. Here's how the conclusion can be
structured:

Winning Scenario:

If the player successfully guesses all the letters in the word within the allowed
number of attempts, display a congratulatory message.

Optionally, you can display the complete word once again to reinforce their
success.

Example: "Congratulations! You guessed the word correctly. You win!"

Losing Scenario:

If the player exhausts all their attempts without correctly guessing the word,
display a message indicating their loss.

Additionally, reveal the complete word to the player so they know the solution.

Example: "Sorry, you ran out of attempts! The word was 'programming'. Better
luck next time!"

Ending Remarks:

Provide a closing message to encourage the player to play again or thank them for
playing.

Example: "Thanks for playing Hangman! Would you like to play again?"

Here's an example of how you can implement the conclusion within the Hangman
game code provided earlier:

This conclusion section ensures that players receive clear feedback on their
performance and are given an opportunity to continue playing or exit the game
gracefully.

4.9 REFFERENCES:
When referencing the implementation of the Hangman game in Python or any
other programming language, you typically don't need specific references unless
you're directly quoting or borrowing code from a particular source. However, if
you're learning about game development, Python programming, or algorithms
related to Hangman, here are some general references you might find helpful:

Python Documentation:

Official Python documentation (https://docs.python.org) provides extensive


resources and tutorials for learning Python programming, including syntax, data
structures, and more.

Online Courses and Tutorials:

Websites like Coursera (https://www.coursera.org), Udemy


(https://www.udemy.com), and Codecademy (https://www.codecademy.com)
offer various Python courses and tutorials, including game development.

Books:

"Automate the Boring Stuff with Python" by Al Sweigart covers practical Python
programming for beginners and includes chapters on game development.

"Invent Your Own Computer Games with Python" by Al Sweigart is another


excellent resource specifically focused on game development with Python.

Hangman Algorithm and Strategies:

If you're interested in the algorithmic aspects of Hangman, you can explore


resources on word guessing strategies, including strategies for maximizing the
chances of winning.

GitHub Repositories and Open Source Projects:

You can explore open-source Hangman implementations on platforms like


GitHub to see how others have approached building the game in Python and gain
insights into coding practices and techniques.

Python Game Development Libraries:


Consider using game development libraries like Pygame or Arcade. While these
may add complexity compared to a console-based implementation, they provide
more advanced features for graphics and user interaction.

By leveraging these resources, you should be well-equipped to develop your own


Hangman game using Python. Good luck with your project!

You might also like