JSPM's
Rajarshi Shahu College of Engineering,
Tathwade Pune-33
(An Autonomous Institute Affiliated to Savitribai
Phule Pune University)
2024-25
Department of Electronics and Telecommunication
Engineering
PYTHON & DATA SCIENCE LAB
MINI PROJECT REPORT
Title:-Simple Voting System
StudentName: Lochan Kolhe
Purva Deshmukh
Roll No. EC2227
EC2233
PRN No. RBT23ET039
RBT23ET052
Under Supervision of
[Link]
INDEX
Sr. No. CONTENT PAGE NO
1. Introduction
2. Problem Statement
3. Methodology and working
4. Flowchart
5. Code
6. Result
7. Advantage & Disadvantage
8. Conclusion
1
Introduction:
A voting system is a crucial tool for gathering opinions or making decisions in a democratic and transparent
manner. In this project, we created a basic command-line voting system that allows users to vote for one of
the three candidates: Alice, Bob, or Charlie. The system collects votes until the user types 'exit', at which
point the total votes for each candidate are displayed.
This project is designed to demonstrate basic concepts of loops, conditionals, and input handling in Python,
providing a simple implementation of a voting system.
Problem Statement:
In many real-world scenarios, voting systems are used to collect public opinion or make decisions. The
challenge here is to build a basic voting system where users can cast their votes for one of three candidates.
The system should:
Continuously prompt the user for a vote until they choose to exit
Track the votes for each candidate.
Display the final result after the voting session ends.
Methodology and Working:
Initialization:We define variables to store the number of votes for each candidate: Alice, Bob, and Charlie.
1. User Input:The system prompts the user to vote for one of the candidates or to type 'exit' to stop
voting.
Vote Validation:If the user types a valid candidate's name (Alice, Bob, or Charlie), the
corresponding vote count is increased.
If the user types 'exit', the voting session stops, and the final result is displayed.
Any invalid input is handled by displaying a message asking the user to enter a valid candidate name.
Looping:The process repeats until the user types 'exit'.
Output:The system outputs the final number of votes for each candidate after the voting session
ends.
1
Flowchart
start
Initialize Vote Counts (Alice, Bob, Charlie = 0)
Vote
Input Vote (Vote for Alice, Bob, or Charlie, or type 'exit')
If "exit": Break the loop
If "Alice": Increment Alice's Vote Count
If "Bob": Increment Bob's Vote Count
If "Charlie": Increment Charlie's Vote Count
Else: Print Invalid Candidate Message
Display Results
End
1
Code
def voting_system():
Alice_votes = 0
Bob_votes = 0
Charlie_votes = 0
while True:
vote = input("Vote for Alice, Bob, or Charlie (type 'exit' to stop): ")
if vote == 'exit'
break
elif vote == 'Alice'
Alice_votes += 1
elif vote == 'Bob':
Bob_votes += 1
elif vote == 'Charlie':
Charlie_votes += 1
else:
print("Invalid candidate! Please vote for Alice, Bob, or Charlie.")
print("\nVoting Results:")
print("Alice:", Alice_votes, "votes")
print("Bob:", Bob_votes, "votes")
print("Charlie:", Charlie_votes, "votes")
if __name__ == "__main__":
voting_system()
Output
Vote for Alice, Bob, or Charlie (type 'exit' to stop): Alice
Vote for Alice, Bob, or Charlie (type 'exit' to stop): Alice
Vote for Alice, Bob, or Charlie (type 'exit' to stop): Bob
Vote for Alice, Bob, or Charlie (type 'exit' to stop): exit
Voting Results:
1
Alice: 2 votes
Bob: 1 votes
Charlie: 0 votes
Advantages & Disadvantages:
Advantages:
Simplicity:The system is easy to understand and implement, providing a basic voting
mechanism.
Real-time Vote Counting:
The votes are counted in real-time, and the system gives immediate feedback after each
vote.
Easy to Extend:
The code is simple enough to allow for easy modifications, such as adding more
candidates or changing the method of input.
User-friendly:
The program handles invalid inputs gracefully, guiding the user to provide valid votes.
Disadvantages:
Limited Functionality:
The system is basic and doesn't have features like vote validation (e.g., preventing
multiple votes from the same user or IP address).
No Data Persistence:
The system doesn't save the votes permanently; once the program is closed, all the data
is lost.
No Vote Security:
There is no mechanism to ensure that votes are legitimate, and there's no way to verify
if a vote was cast multiple times by the same user.
Manual Voting:
The user must manually input each vote. There is no automation or batch processing
for large-scale voting.
1
Conclusion:
The "Simple Voting System" is an introductory project that demonstrates the
fundamentals of a voting process implemented using Python. It collects votes from
users, tracks them in real-time, and displays the final result. The project serves as a
good foundation for more complex voting systems, which can incorporate additional
features like security, data persistence, and scalability.
While the current system is basic, it provides essential functionality and serves as a
learning tool for understanding how voting systems work in software development.
Future improvements can include features like database integration, online voting, and
user authentication.