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

Python Project Report-1

The document describes a number crossword puzzle project created using Python. It includes an abstract describing the project, sections on challenges, requirements, contributions, code, flowchart and output. The project is a desktop application that allows users to play a 2x2 number crossword puzzle game and track their score and time.

Uploaded by

nupur2011k
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Python Project Report-1

The document describes a number crossword puzzle project created using Python. It includes an abstract describing the project, sections on challenges, requirements, contributions, code, flowchart and output. The project is a desktop application that allows users to play a 2x2 number crossword puzzle game and track their score and time.

Uploaded by

nupur2011k
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Pimpri Chinchwad College of Engineering, Pune

DEPARTMENT OF ELECTRONICS AND TELE-


COMMUNICATION ENGINEERING

MINI PROJECT REPORT AY. 23-24 Sem II


Project Title: Number Crossword Puzzle

Name: Shweta Jadhav


Roll No.: FY23F126
Division: F
Subject: Problem Solving with Python Programming
Teacher: Mrs. Suwarna shete Ma’am

1
CONTENT

Sr. Title Page


No. No.

1 Abstract 3

2 Introduction 4

3 Challenges 5

4 My Contribution 6

5 Requirements 8

6 Python code 9

7 Flow Chart 14

8 Output 16

9 Applications 20

10 Future Scope 22

11 Conclusion 24

2
ABSTARCT:
"The number crossword puzzle project is an interactive and engaging game designed
to challenge players' logical thinking and numerical skills. The puzzle consists of a
2X2, with some cells pre-filled with digits. The objective is to fill in the remaining
empty cells with the digits 1 through 9, ensuring that each row, column, and subgrid
contains each digit exactly once.Players interact with the puzzle through a user-
friendly graphical interface, where they can click on empty cells to input their
answers. The game provides feedback in real-time, indicating incorrect entries and
highlighting completed rows, columns, The project incorporates various features to
enhance the gaming experience, including a timer to track the player's progress, a
scoring system to reward correct answers and penalize mistakes, and multiple
difficulty levels to cater to players of different skill levels. Additionally, the game
offers hints and solutions for players who may need assistance or want to check their
answers.The number crossword puzzle project aims to provide a fun and educational
experience for players of all ages, promoting critical thinking, problem-solving, and
numeracy skills. It can be enjoyed as a standalone game or integrated into educational
platforms to support mathematics learning and cognitive development.The number
crossword puzzle project offers a dynamic and customizable gaming experience that
combines entertainment with intellectual challenge, making it an ideal choice for
puzzle enthusiasts and educators alike."

3
INTRODUCTION:
Problem Statement:
The objective is to develop a desktop application that allows users to play a Number
Crossword Puzzle Game. The game presents players with a 2x2 grid where they must
fill in numbers such that the sums of rows and columns match given clues. The
application should include features like a timer, score tracking, and user interaction
for solving puzzles.

The Number Crossword Puzzle Game is a desktop application developed using the
tkinter library in Python. Upon launching the application, players are greeted with a
main menu where they can choose to start a new puzzle. Clicking the "2x2 Puzzle"
button opens a new window displaying a 2x2 grid puzzle with row and column clues.

Players interact with the grid by entering numbers based on the given clues. They can
then click the "Check" button to verify their solution. If the solution is correct, a
congratulatory message is displayed, the player's score is incremented, and they are
prompted to solve more puzzles or return to the main menu. If the solution is
incorrect, an error message is shown, and the timer resumes from where it left off.

4
CHALLENGES:
1. Random Puzzle Generation: Generating random puzzles with correct row and
column sums while ensuring they are solvable and provide an enjoyable challenge.

2. Timer Implementation: Designing a timer that accurately tracks the time taken by
the player to solve the puzzle, starting when the puzzle is displayed and stopping
when the player checks their solution.

3. User Interface Design: Creating an intuitive and visually appealing user interface
with clear grid layout, input fields, buttons, and labels, while ensuring ease of
interaction.

4. User Input Validation: Implementing input validation to ensure that only valid
numbers are entered into the grid and preventing incorrect or invalid inputs.

5. Solution Checking Mechanism: Developing a mechanism to check the player's


solution against the given clues, verifying if the sums of rows and columns match,
and providing appropriate feedback.

6. Score Tracking and Display: Keeping track of the player's score based on
successful puzzle completions and displaying the score prominently to provide
feedback and motivation.

7. Menu Integration: Integrating a main menu into the application to provide options
for starting new puzzles, accessing instructions, and exiting the game

5
MY CONTRIBUTION:
1. GUI Design and Layout:

Designed the graphical user interface (GUI) for the Math Puzzle(Number crossword)
project. This included defining the layout, organizing widgets, and determining the
visual elements such as buttons, labels, and frames.

2. Widget Configuration:

Configured various GUI widgets to ensure they functioned correctly and provided the
desired interaction for users. This involved setting attributes such as text, font, colour,
size, position, and event handling.

3. Button Functionality:

Implemented button functionality to enable users to interact with the application. This
included defining button click actions, such as starting puzzles, submitting answers,
navigating between screens, and accessing menu options.

4. Input Fields and Validation:

Integrated input fields within the GUI to allow users to input their answers.
Additionally, I implemented input validation to ensure the entered data met the
required criteria and provided appropriate error messages for invalid inputs.

5. Timer Implementation:

Incorporated a timer feature into the GUI to track the time elapsed during puzzle-
solving tasks. This involved updating the timer display dynamically and handling
timer events to start, stop, and reset the timer as needed.

6. Score Tracking:

I implemented score tracking functionality within the GUI to keep track of users'
performance and progress. This included updating the score display based on correct
or incorrect answers and storing scores for future reference.

7. Menu Options and Navigation:

Designed menu options within the GUI to provide users with additional
functionalities such as accessing different puzzle types, returning to the main menu,
or exiting the application. You ensured smooth navigation between different scree
Testing and Debugging:

6
8. Testing and debugging:

Throughout the development process, I conducted thorough testing and debugging to


ensure the project's stability, functionality, and accuracy. My attention to detail and
dedication to quality assurance helped identify and resolve issues related to
functionalities.

7
REQUIREMENTS:
Libraries:

1. tkinter: Python's standard GUI library used for creating the graphical user
interface.

Description: Used to build the desktop application's interface, including buttons,


labels, entry fields, and windows

2. time: This module provides various time-related functions. For related


functionality, see also the datetime and calendar modules.

Functions :

1.generate_clues(): Generates random clues for rows and columns to create unique
puzzles for each gameplay session.

2. create_widgets(): Creates the user interface elements for the puzzle window,
including labels, entry fields, buttons, and the timer display.

3. start_timer(): Initiates the timer when the puzzle is displayed, starting from zero
and updating every second until the player checks their solution.

4. update_timer(): Updates the timer display every second while the puzzle is
being solved, providing real-time feedback on the time taken.

5. reset_puzzle(): Resets the puzzle and timer, generating a new puzzle for the
player to solve and starting the timer again.

6. check_solution(): Validates the player's solution against the given clues,


checking if the sums of rows and columns match and providing feedback
accordingly.

7. show_main_menu(): Closes the puzzle window and returns to the main menu,
allowing the player to start a new puzzle or exit the game.

8. open_number_crossword_window(): Opens the puzzle window when the "2x2


Puzzle" button is clicked on the main menu.

9. exit():destroys the puzzle window

10. riddle messagebox(): used to display message

8
PYTHON CODE:
import tkinter as tk
from tkinter import messagebox
import random
import time

class NumberCrossword:

def __init__(self, parent,score=0):


self.parent = parent

self.root = tk.Toplevel(parent)
self.root.title("Number Crossword Puzzle")

self.root.geometry("400x400")
self.root.configure(bg="lightblue")

self.score = score # Initialize score


self.timer_running = False
self.time_left = 30
self.start_time = None

self.create_widgets()

# Start the timer


self.start_timer()

def generate_clues(self):
# Generate random clues for rows and columns
self.row_clues = [random.randint(1, 10) for _ in
range(2)]

# Calculate the sum of the rows


row_sum = sum(self.row_clues)

# Generate random clues for columns


self.column_clues = [random.randint(1, row_sum) for _
in range(2)]
for i in range(len(self.column_clues)):
column_sum = sum(self.row_clues[j] for j in
range(len(self.row_clues)) if j != i)
self.column_clues[i] = column_sum
def create_widgets(self):
9
self.generate_clues()

# Frame to hold puzzle elements


puzzle_frame = tk.Frame(self.root,
bg="lightblue",height="14")
puzzle_frame.pack(padx=10, pady=10)

# Display row clues


for i, clue in enumerate(self.row_clues):
tk.Label(puzzle_frame, text=str(clue), width=5,
height=2, relief="groove", bg="lightgreen").grid(row=i,
column=0, padx=5, pady=5)

# Display column clues


for j, clue in enumerate(self.column_clues):
tk.Label(puzzle_frame, text=str(clue), width=5,
height=2, relief="groove", bg="lightgreen").grid(row=2,
column=j+1, padx=5, pady=5)

# Entry fields for the grid


self.entries = []
for i in range(2):
row_entries = []
for j in range(2):
entry = tk.Entry(puzzle_frame, width=5,
font=('Helvetica', 12))
entry.grid(row=i, column=j+1, padx=5, pady=5)
row_entries.append(entry)
self.entries.append(row_entries)

# Check button
self.check_button = tk.Button(self.root, text="Check",
command=self.check_solution, bg="lightgrey", width=8,
height=2, font=('Helvetica', 12))
self.check_button.pack(pady=10)

# Timer label
self.timer_label = tk.Label(self.root, text="Time
left: 30", bg="pink", font=('Helvetica', 12))
self.timer_label.pack(pady=10)

# Score label
self.score_label = tk.Label(self.root, text=f"Score:
{self.score}", font=('Helvetica', 12))
10
self.score_label.pack(pady=10)

# Menu button
self.menu_button = tk.Button(self.root,
text="Menu",bg="lightgrey", command=self.show_main_menu,
width=8, height=2, font=('Helvetica', 12))
self.menu_button.pack(pady=10)

def start_timer(self):
if not self.timer_running:
self.timer_running = True
self.start_time = time.time()
self.update_timer()

def update_timer(self):
if self.time_left > 0 and self.timer_running:
self.timer_label.config(text=f"Time left:
{self.time_left}")
self.time_left -= 1
self.root.after(1000, self.update_timer)
else:
self.timer_running = False
if self.time_left == 0:
response = messagebox.askyesno("Time's Up!",
"Time's up! Would you like to try again?")
if response:
open_number_crossword_window()
self.reset_puzzle()
else:
self.root.destroy()
self.parent.deiconify() # Show the main
menu window

def reset_puzzle(self):
self.time_left = 30
self.create_widgets() # Generate new puzzle widgets
self.start_timer() # Start the timer again

def check_solution(self):
# Stop the timer
self.timer_running = False
elapsed_time = time.time() - self.start_time

# Check sum of rows


11
for i, clue in enumerate(self.row_clues):
row_sum = sum(int(entry.get() or 0) for entry in
self.entries[i])
if row_sum != clue:
messagebox.showerror("Incorrect", f"Sum of
numbers in Row {i+1} is incorrect.")
self.start_timer() # Resume the timer from
where it stopped
return

# Check sum of columns


for j, clue in enumerate(self.column_clues):
column_sum = sum(int(entry.get() or 0) for entry
in [row[j] for row in self.entries])
if column_sum != clue:
messagebox.showerror("Incorrect", f"Sum of
numbers in Column {j+1} is incorrect.")
self.start_timer() # Resume the timer from
where it stopped
return

# If all checks pass, show congratulatory message


time_taken = int(elapsed_time)
self.score += 1 # Increase score
self.score_label.config(text=f"Score: {self.score}")
messagebox.showinfo("Congratulations", f"Puzzle solved
successfully!\nTime taken: {time_taken} seconds\n your score
is: {self.score}")

response = messagebox.askyesno("More Puzzles", "Would


you like to solve more puzzles?")
self.score_label.config(text=f"Score: {self.score}")
if response:
self.root.destroy()
open_number_crossword_window(self.score)

#self.reset_puzzle() # Generate new puzzle and


start timer immediately

else:
self.root.destroy()
self.parent.deiconify() # Show the main menu
window
12
def open_number_crossword_window(prev_score):
#self.score+=1
root = tk.Tk()
app = NumberCrossword(root,prev_score)
def show_main_menu(self):
self.root.destroy()
self.parent.deiconify() # Show the main menu window
def exit(self):
self.root.destroy()
def display_riddle_instructions():
instructions = "Welcome to the Number Crossword Puzzle
Game!\n\nTo solve the puzzle, you need to fill in the 2x2 grid
with numbers " \n"such that the sums of rows and columns match
the given clues.\n\n" \"LETS START\n your score and time will
be recorded"

messagebox.showinfo("Instructions", instructions)
open_number_crossword_window(score=0)
def open_number_crossword_window(score):
root.withdraw() # Hide the main window
game = NumberCrossword(root,score)

if __name__ == "__main__":
root = tk.Tk()
root.title("Main Menu")
root.geometry("250x150")
root.configure(bg="lightblue")
label = tk.Label(root, text="Welcome to Number Crossword
Puzzle!",font="arial 26 bold",bg="pink")
label.pack(padx=20,pady=10)
riddles_button = tk.Button(root, text="2x2 Puzzle",
command=display_riddle_instructions, bg="lightgreen",
width=13, height=3, font=('Helvetica', 12))
riddles_button.pack(pady=10)
riddles_button = tk.Button(root, text="EXIT", d=exit,
bg="lightgreen", width=10, height=3, font=('Helvetica', 12))
riddles_button.pack(pady=10)

root.mainloop()

13
FLOW CHART:

Star

Display main window


”welcome “

Select 2x2 puzzle

Display riddle instruction by


calling

Generate riddle randomly with the


help of row and column

Display main puzzle by calling


open puzzle window

Initially Assign score to zero


and timer 30

Enter answer in respective grids


and decrement timer by one sec

A
A
14
A
A

Yes IIs No
answer
correct

Display score and time Display the sum of which


taken row or column is
incorrect

Display message box Display


Is times up
asking for more riddles
timer mesg and
with yes or no option
over call update
timer

No
Keep trying and
agree filling grids
Back to main
menu

Yes

Call reset puzzle window


and update score

Stop

15
OUTPUT:
Main window

When clicked on puzzle Button:

16
When clciked on ok

When clicked on check:

1.If answer is correct

17
When clicked on ok:

When clicked on yes

18
2. When answer is not correct

Times up:

When clicked on Menu:

BACK TO MAIN MENU

19
APPLICATIONS:
The Number Crossword Puzzle application serves as an interactive and engaging
game designed to entertain and challenge users. Its primary purpose is to provide
users with a fun and educational experience centered around numerical puzzles.

Here are some key applications of the Number Crossword Puzzle:

1 .Entertainment:

Number crossword puzzles offer a fun and stimulating leisure activity for people
looking to challenge themselves mentally while enjoying a relaxing pastime. They
provide a welcome break from screen-based entertainment and offer a refreshing
alternative for individuals seeking intellectually stimulating activities.

2. Educational Tool:

The puzzle game can be utilized as an educational tool to enhance numerical skills,
problem-solving abilities, and critical thinking. It encourages users to apply
mathematical concepts in a practical and engaging context

3. Cognitive Development:

By presenting users with numerical challenges, the puzzle game promotes cognitive
development. It encourages users to exercise their memory, attention, and logical
reasoning skills while solving puzzles.

4. Stress Relief:

Engaging in puzzle-solving activities can serve as a form of stress relief and


relaxation for users. The game offers a meditative and immersive experience that
allows users to focus their attention and The Number Crossword Puzzle application
serves as an interactive and engaging game designed to entertain and challenge users.
Its primary purpose is to provide users with a fun and educational experience
centered around numerical puzzles.

6. Social Interaction:

The puzzle game can be enjoyed individually or as a social activity among friends
and family members. Users can collaborate or compete with others to solve puzzles,
fostering social interaction and teamwork.

20
7.Mathematics Enrichment:

Number crossword puzzles can be used as supplementary materials to enrich


mathematics education beyond the standard curriculum. They can introduce advanced
mathematical concepts in a playful and accessible manner, encouraging students to
explore mathematical principles in a non-traditional format.

21
FUTURE SCOPE:
The Number Crossword Puzzle application has several potential future enhancements
and expansions that can be explored to further improve its functionality and appeal.
Here are some future scope ideas:

1.Difficulty Levels:

Implement multiple difficulty levels (easy, medium, hard) to cater to users with
varying skill levels..

2.Customization Options:

Allow users to customize their puzzle-solving experience by adjusting parameters


such as grid size, number range, and time limits. This customization feature can
enhance user engagement and satisfaction.

3.Multiplayer Mode:

Introduce a multiplayer mode where users can compete against each other in real-
time or collaborate to solve puzzles together. This feature can add a social dimension
to the game and promote friendly competition among users.

4.Achievements and Leaderboards:

Implement a system of achievements and leaderboards to track users' progress,


reward their accomplishments, and foster a sense of competition. Users can earn
badges, trophies, or ranks based on their performance in solving puzzles.

5.Integration with Learning Platforms:

Partner with educational institutions or online learning platforms to integrate the


puzzle game into educational curricula or online courses. This integration can help
reinforce mathematical concepts and engage students in interactive learning
experiences.

Mobile Application: Develop a mobile application version of the puzzle game for
smartphones and tablets, making it accessible to a wider audience. The mobile app
can offer additional features such as offline play, push notifications, and social
sharing options.

6.Analytics and Feedback:

Collect user data and feedback to analyze usage patterns, identify areas for
improvement, and tailor the game experience to meet users' preferences and needs..
22
7.Localization and Internationalization:

Translate the puzzle game into multiple languages and adapt it to different cultural
contexts to make it accessible to users worldwide.

8.Integration with Other Platforms:

Explore opportunities to integrate the puzzle game with other digital platforms, such
as social media networks, gaming portals, or online marketplaces.

23
CONCLUSION:
The development and application of the number crossword puzzle project showcase
the versatility and effectiveness of GUI programming in Python. Through this
project, various features and functionalities were implemented to create an engaging
and interactive puzzle-solving experience. The project began with the design and
implementation of a graphical user interface (GUI) using the Tkinter library,
providing a visually appealing platform for users to interact with the puzzle. The GUI
included buttons, labels, entry fields, and other widgets to facilitate puzzle-solving
and user interaction. These puzzles challenged users to fill in the grid with numbers
while adhering to specific sum constraints for each row and column. Users could
input their answers directly into the grid, and the program would validate their
submissions to ensure accuracy. Additional features such as a timer to track the
duration of puzzle-solving sessions, a scoring system to evaluate user performance,
and a menu option to navigate between different puzzle types and difficulty
levels.The project also demonstrated the integration of error handling mechanisms to
address user input errors and provide informative feedback to the user. These puzzles
offer a fun and engaging way to enhance problem-solving skills, mathematical
reasoning, and cognitive abilities. Number crossword puzzle project exemplifies the
power of GUI programming in Python to create interactive and educational
applications. By incorporating user-friendly interfaces, engaging gameplay
mechanics, and thoughtful features, the project aims to provide users with an
enjoyable and rewarding puzzle-solving experience while promoting learning and
mental stimulation.

24

You might also like