Class Xii Computer Science Project- Final
Class Xii Computer Science Project- Final
SCHOOL, PALLIKARANAI
Project File on
VOTER MANAGEMENT SYSTEM
Session- 2024-2025
CLASS: XII D
REGISTRATION NO:
Teacher-In-Charge
Ms. G Sivaneswari
D.A.V. SCHOOL – PALLIKARANAI
Name : Roll no :
CERTIFICATE
Teacher-In-Charge
Internal Examiner
I would also like to thank my parents, friends and all the members who
contributed to this project was vital for the success of the project.
I am grateful for their constant support and help.
CONTENTS
▪ OVERVIEW OF PYTHON 1
➢ Key Features of Python
➢ Applications of Python
▪ OVERVIEW OF MYSQL 3
➢ Key features
➢ Common Uses
▪ HARDWARE AND SOFTWARE 5
REQUIREMENTS
▪ SOURCE CODE 7
▪ OUTPUT 22
▪ TABLES USED IN CODE 27
➢ Voters Table
➢ Candidates Table
➢ Areas Table
▪ FUNCTIONS USED IN CODE 29
➢ create_tables(cursor)
➢ data_insertion(cursor,mycon)
➢ voter_details(cursor, voter_id)
➢ candidate_details(cursor, area_id)
➢ area_details(cursor, area_id)
➢ voters_in_area(cursor, area_id)
➢ number_voters(cursor, area_id)
➢ voter_edit(cursor)
➢ voter_update(cursor)
➢ show_error()
➢ close_connection(cursor)
▪ CONCLUSION 34
▪ BIBILIOGRAPHY 35
Overview of Python
▪ Interpreted Language
o Python executes code line by line, which simplifies testing
and debugging.
1|Page
Applications of Python
2|Page
Overview of MySQL
Key Features
• Cross-Platform Compatibility: Works on various operating
systems, including Windows, macOS, and Linux.
• Scalability: Supports both small-scale projects and large,
enterprise-level applications.
• High Performance: Optimizes data retrieval and query speed
through techniques like indexing, caching, and partitioning.
• Data Integrity and Security: Ensures data accuracy and offers
robust security measures to protect against unauthorized access.
• Multi-User Access: Allows multiple users to access and modify
data simultaneously.
• Transaction Support: Ensures reliable data operations with
support for ACID (Atomicity, Consistency, Isolation, Durability)
properties.
3|Page
Common Uses
• Web Development: Powers popular content management systems
(CMS) like WordPress, Joomla, and Drupal.
• Web Applications: Frequently used with frameworks like Django,
Laravel, and PHP to build dynamic websites.
• Data Analytics and Reporting: Supports data warehousing and
reporting tools for business intelligence.
Advantages
• Ease of Use: Simple to install and set up, even for beginners.
• Flexibility: Suitable for a wide range of projects, from small
websites to large-scale data applications.
• Cost-Effective: Being open-source, it is free to use, making it an
economical option for developers.
4|Page
Hardware and Software Requirements
Hardware Requirements
1. Computer: Any computer or laptop with at least an Intel i3 or
AMD Ryzen 3 processor is enough, as the program is not very
demanding.
2. RAM: A minimum of 4 GB is recommended, though 8 GB or
more would ensure better performance, especially if other
applications are running.
3. Storage: Basic storage (at least 500 MB) is needed for Python,
required libraries, and the votermanagementsystem.py file where
data is stored.
4. Input Devices: A keyboard and mouse are required to enter and
manage data within the program.
5. Display: Any standard monitor or laptop screen will work for
viewing program output and navigating the menu.
5|Page
Software Requirements
1. Operating System:
o Compatible with Windows, macOS, or Linux. Python and its
libraries, like pickle, are supported on all these platforms.
2. Python Environment:
o Python: Version 3.x (preferably 3.7 or newer for the latest
features and library compatibility).
o Python Standard Library: The tkinter module, part of
Python's standard library, is used here for creating graphical
user interfaces (GUIs). No additional installation is needed
if Python is already installed.
3. IDE:
o IDEs: Tools like PyCharm, VS Code, or IDLE can make
coding easier with features like debugging and code
suggestions.
4. Command-Line Interface (CLI):
o A command-line tool, such as Command Prompt (Windows),
Terminal (macOS or Linux), or a terminal within an IDE, is
needed to run the program if not using an IDE.
5. Database System:
o To managing datasets, a database like MySQL is used. Even
SQLite can be used. Both databases work well with Python
and offer more features and data handling capabilities.
6|Page
SOURCE CODE
cursor.execute(create_candidates_table)
cursor.execute(create_areas_table)
cursor.execute(create_voters_table)
8|Page
('Anita Kapoor', 45, 'Female', 3),
('Shyam Narayan', 50, 'Male', 4),
('Kiran Malhotra', 29, 'Female', 4),
('Deepak Sharma', 65, 'Male', 5),
('Rekha Banerjee', 31, 'Female', 5)]
insert_query = "INSERT INTO voters (name,
age, gender, area_id) VALUES (%s, %s, %s, %s);"
cursor.executemany(insert_query,
voter_data)
mycon.commit()
areas_data=[(1, 'Panauti', 4),
(2, 'Bandra', 5),
(3, 'Jayanagar', 3),
(4, 'Raj Lake', 6),
(5, 'Indira Nagar', 2)]
insert_query = "INSERT INTO areas (area_id,
area_name, candidate_count) VALUES (%s, %s,
%s);"
cursor.executemany(insert_query,
areas_data)
mycon.commit()
candidates_data = [
('Rahul Mehra', 1, 'Panauti', 45,
'National Party'),
('Priya Kapoor', 2, 'Bandra', 37,
'People\'s Alliance'),
9|Page
('Arjun Rao', 3, 'Jayanagar', 52,
'United Front'),
('Sneha Iyer', 4, 'Raj Lake', 40,
'Progressive Alliance'),
('Vikram Bhatia', 5, 'Indira Nagar',
33, 'National Party'),
('Anita Desai', 1, 'Panauti', 50,
'People\'s Alliance'),
('Ramesh Singh', 2, 'Bandra', 43,
'United Front'),
('Deepa Nair', 3, 'Jayanagar', 39,
'National Party'),
('Suresh Kumar', 4, 'Raj Lake', 55,
'People\'s Alliance'),
('Leela Gupta', 5, 'Indira Nagar', 47,
'Progressive Alliance')]
10 | P a g e
#Calling the above functions
create_tables(cursor)
data_insertion(cursor,mycon)
11 | P a g e
area_id = %s"
cursor.execute(query, (area_id,))
i=cursor.fetchall()
root = Tk()
root.title('Candidate Details')
root.geometry("10000x10000")
count=1
for result in i:
d=f"NAME: {result[0]}\nArea ID:
{result[1]}\nArea Name: {result[2]}\nAge: \
{result[3]}\nParty name: {result[4]}"
details_label = Label(root,text =
f"CANDIDATE DETAILS\n\nCandidate {count}
details \n{d}",font=("Times New Roman",
20),bg="#3B1C32",fg="#FCF596", justify="left",
padx=50, pady=50)
details_label.pack( side = TOP)
count+=1
root.mainloop()
12 | P a g e
result=cursor.fetchone()
root = Tk()
root.title('Area Details')
root.geometry("1000x1000")
d=f"Area ID: {result[0]}\nArea Name:
{result[1]}\nCandidate Count: {result[2]}"
label = Label(root,text = f"AREA
DETAILS\n\n {d}",
font=("Times New Roman",
20),bg="#3B1C32",fg="#FCF596",
justify="left", padx=50,
pady=50)
label.pack( side = TOP)
root.mainloop()
13 | P a g e
count=1
for result in i:
d=f"ID: {result[0]}\nName:
{result[1]}\nAge: {result[2]}\nGender:
{result[3]}\nArea ID: {result[4]}"
def fun(d):
label = Label(roo1,text = f"VOTERS
IN AN AREA\n\n {d}",
font=("Times New Roman",
10),bg="#3B1C32",fg="#FCF596",
justify="left", padx=20,
pady=20)
label.pack( side = TOP)
btn1 = Button(root,text = f"Voter
{count} details",font=("Papyrus",
24),bg="green",fg="white",padx=10,pady=10,comma
nd=lambda d=d: fun(d))
btn1.pack( side = TOP)
count+=1
root.mainloop()
14 | P a g e
JOIN areas AS b ON a.area_id =
b.area_id
WHERE a.area_id = %s
GROUP BY b.area_name;"""
cursor.execute(query, (area_id,))
t = cursor.fetchone()
if t:
message = f'The number of voters in
{t[1]} with ID {area_id} is {t[0]}'
else:
message = f'No voters found for area
with ID {area_id}'
root = Tk()
root.title("Voter Count")
root.geometry("1000x700")
label = Label(root, text = f"NUMBER OF
VOTERS IN AN AREA\n\n {message}",
font=("Times New Roman",
20),bg="#3B1C32",fg="#FCF596",
justify="left", padx=20,
pady=20)
label.pack(pady=20)
root.mainloop()
15 | P a g e
iD=int(input("Enter voter ID: "))
query='select * from voters where
voter_id=%s'
cursor.execute(query,(iD,))
old=cursor.fetchone()
name=input('Enter name: ')
age=int(input('Enter age: '))
gender=input('Enter gender: ')
areaID=int(input('Enter area ID: '))
update_query = """UPDATE voters SET name =
%s, age = \
%s, gender = %s, area_id = %s WHERE voter_id =
%s;"""
cursor.execute(update_query, (name, age,
gender, areaID, iD))
mycon.commit()
query='select * from voters where
voter_id=%s'
cursor.execute(query,(iD,))
new=cursor.fetchone()
root = Tk()
root.title("Voter Count")
root.geometry("1000x1000")
message=f'Old Details:{old} \nNew Details:
{new}'
label = Label(root, text=message,
16 | P a g e
font=("Times New Roman",
20),bg="#3B1C32",fg="#FCF596",
justify="left", padx=20,
pady=20)
label.pack(pady=20)
root.mainloop()
print("Voter details edited successfully.")
17 | P a g e
20),bg="#3B1C32",fg="#FCF596",
justify="left", padx=20,
pady=20)
label.pack(pady=20)
root.mainloop()
18 | P a g e
print('Enter 3 to view area details')
print('Enter 4 to view all voters in area')
print('Enter 5 to view the number of voters in
an area ')
print('Enter 6 to edit voter details')
print('Enter 7 to insert new voter details')
while True:
ch=int(input('Enter Choice: '))
if ch==1:
vID=int(input('Enter voter ID: '))
if isinstance(vID, int):
t=voter_details(cursor,vID)
print('Voter details displayed
successfully')
else:
show_error(message)
elif ch==2:
areaID=int(input('Enter area ID: '))
if isinstance(areaID, int):
candidate_details(cursor, areaID)
print('Candidate details displayed
successfully')
else:
show_error(message)
elif ch==3:
19 | P a g e
areaID=int(input('Enter area ID: '))
if isinstance(areaID, int):
area_details(cursor, areaID)
print('Area details displayed
successfully')
else:
show_error(message)
elif ch==4:
area_id=int(input('Enter area ID: '))
if isinstance(area_id, int):
voters_in_area(cursor, area_id)
print('Details of all voters in an
area displayed successfully')
else:
show_error(message)
elif ch==5:
area_id=int(input('Enter Area ID: '))
if isinstance(area_id, int):
number_voters(cursor,area_id)
print('The number of voters in an
area displayed successfully')
else:
show_error(message)
elif ch==6:
voter_edit(cursor)
20 | P a g e
print('Voter details edited
successfully')
elif ch==7:
voter_update(cursor)
('Added voter details successfully')
else:
show_error()
choice=input('DO YOU WANT TO CONTINUE?
(Y/N)')
if choice in 'Nn':
print('Thank You')
break
21 | P a g e
OUTPUT
22 | P a g e
• To view voter details
23 | P a g e
• To view number of voters in an area
24 | P a g e
• To view voter details
25 | P a g e
• Error message
26 | P a g e
TABLES USED
• Voters Table
27 | P a g e
• Candidates Table
• Areas Table
28 | P a g e
FUNCTIONS USED IN THE CODE
▪ create_tables(cursor)
The create_tables(cursor) function sets up three
database tables (voters, areas, and candidates) for a
voting system. It uses the provided cursor to execute CREATE
TABLE statements, ensuring the tables are only created if they
don’t already exist. These tables store details about voters,
electoral areas, and candidates, helping structure data for an
election management application.
▪ data_insertion(cursor,mycon)
The data_insertion(cursor, mycon) function
populates the database tables (voters, areas, and
candidates) with predefined data for an election management
system. It uses executemany() to efficiently insert multiple
records into each table and commits the changes to the database.
This function is crucial for setting up initial data, enabling the
application to operate with sample entries for testing or
demonstration purposes.
29 | P a g e
▪ voter_details(cursor, voter_id)
The voter_details(cursor, voter_id) function
retrieves and displays the details of a specific voter from the
database using a graphical interface created with tkinter. It fetches
data based on the given voter_id and shows it in a pop-up message
box when a button is clicked. This function helps users easily
access and view individual voter information within a user-
friendly interface.
▪ candidate_details(cursor, area_id)
30 | P a g e
▪ area_details(cursor, area_id)
▪ voters_in_area(cursor, area_id)
31 | P a g e
▪ number_voters(cursor, area_id)
▪ voter_edit(cursor)
32 | P a g e
▪ voter_update(cursor)
▪ show_error()
▪ close_connection(cursor)
33 | P a g e
CONCLUSION
This project has room for improvement. Adding features like better
security, such as password protection or biometric verification, could
make it safer. Turning it into a website would let people access it from
anywhere. Other upgrades, like adding charts for data analysis or
support for multiple languages, could make it more useful for diverse
users.
In conclusion, the Voter Management System is a great starting point
for understanding how technology can improve election management. It
meets its current goals but also shows how future updates could make it
even better. This project highlights the importance of organized systems
and opens up ideas for innovation.
34 | P a g e
BIBILIOGRAPHY
35 | P a g e