0% found this document useful (0 votes)
68 views4 pages

Hangman Game Project

Uploaded by

brisoboban292
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)
68 views4 pages

Hangman Game Project

Uploaded by

brisoboban292
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/ 4

Project Title: Hangman Challenge – A Word

Guessing Game using Python and MySQL

1. Introduction
The "Hangman Challenge" is a text-based game inspired by the classic Hangman puzzle. It is built
using the Python programming language, with the game data stored and managed using a MySQL
database. The aim of this project is to create a simple, interactive, and educational game that
enhances programming logic, user interaction, and database operations. This project is a great
example of how a real-world application can be developed by combining the power of Python and
SQL. By using MySQL to store the words and scores, the game avoids hardcoding and becomes
easier to manage and update. It also demonstrates the concept of persistent storage in a fun and
practical way. The project aligns with the CBSE Class 12 Computer Science practical requirements
and is suitable for showcasing database connectivity, user-defined functions, and modular
programming in Python.

2. Objective
The main objectives of this project are:
- To design and implement a user-interactive word guessing game.
- To understand and demonstrate the integration of Python with MySQL.
- To develop the ability to use SQL queries for storing and retrieving game-related data.
- To provide a basic scoring system using a backend database.
- To create an extendable system where the word bank can be easily updated without modifying the
source code.
- To practice problem-solving, conditional logic, and real-time feedback in terminal-based
applications.

3. Problem Statement
Most beginner-level games in Python rely on static data, such as lists or dictionaries embedded
within the code. This method lacks scalability and flexibility. For example, if the developer wants to
add or remove words, they must edit the source code and re-run the program. This is not ideal,
especially when games are shared or maintained by multiple users.

The problem addressed in this project is how to make a Python-based word guessing game more
dynamic and manageable by integrating it with a MySQL database. By separating data (words,
scores) from the core logic of the game, this project allows easy updates to the word list and score
tracking, while maintaining a clean and efficient Python codebase. This separation of concerns
makes the project scalable and easier to maintain.

4. Tools and Technologies Used


- Programming Language: Python
- Database: MySQL
- Library: mysql-connector-python
- IDE: VS Code / IDLE
- Platform: Windows/Linux
5. System Requirements
- Python 3.x installed
- MySQL Server installed
- mysql-connector-python library
- Command Line Interface (CLI)

6. Database Design
Database Name: hangman_game

Table 1: words
| Field | Type | Description |
|-------|------|-------------|
| id | INT | Primary Key, Auto Increment |
| word | VARCHAR(50) | The word used in the game |

Table 2: players (optional)


| Field | Type | Description |
|-------|------|-------------|
| id | INT | Primary Key, Auto Increment |
| name | VARCHAR(50) | Name of the player |
| score | INT | Player score |
| played_on | TIMESTAMP | Timestamp of the game session |

7. Python Code Explanation


The main Python script does the following:
- Connects to the MySQL database.
- Fetches a random word from the words table.
- Accepts letter-by-letter input from the player.
- Tracks the number of wrong attempts.
- Displays progress after each input.
- At the end, stores the score (if feature is enabled).

Key functions:
- get_random_word()
- display_word()
- update_score()

8. Sample SQL Queries


CREATE DATABASE hangman_game;
USE hangman_game;

CREATE TABLE words (


id INT AUTO_INCREMENT PRIMARY KEY,
word VARCHAR(50) NOT NULL
);

INSERT INTO words (word) VALUES ('python'), ('keyboard'), ('project');


CREATE TABLE players (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
score INT,
played_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

9. Sample Output
Welcome to Hangman!
Guess the word: _ _ _ _ _ _
Wrong guesses left: 6

Enter a letter: p
Correct!
______

...
Game Over! The word was: python
Your score: 70

10. Admin Panel (Optional Feature)


The admin panel allows the admin to:
- Add new words to the database
- Remove or edit existing words
- View the list of words and scores

This can be implemented with a simple menu-based interface in Python using SQL queries.

11. Learning Outcomes


Through this project, I will:
- Learn how to connect Python with a MySQL database.
- Understand how to design and manage a relational database.
- Implement real-time user interaction and input validation.
- Strengthen logical thinking through game design.

12. Advantages of the Project


- Interactive and engaging
- Modular and easy to expand
- Real-world application of Python and MySQL
- Easy to maintain data through the database

13. Limitations
- The game is terminal-based and not graphical.
- Limited to English words only.
- No multiplayer support or advanced levels.

14. Future Scope


- Add a GUI using Tkinter or PyQt.
- Include levels based on difficulty.
- Add support for different languages.
- Implement multiplayer mode.

15. Conclusion
This project will help me enhance my understanding of Python programming and MySQL database
management through a fun and engaging game. It will strengthen my skills in using loops,
conditionals, functions, and database connectivity in real-world applications.

You might also like