In this activity, we will write a Python program that checks whether a person is eligible to vote based on their age. In most countries, the minimum voting age is 18.

Algorithm
- START
- INPUT: Ask the user for their name
- INPUT: Ask the user for their age
- DECISION: Is age >= 18?
- YES → OUTPUT: Print that the person is eligible to vote
- NO → OUTPUT: Print that the person is not eligible and how many years remain
- END

Writing the Python Code
# Voting Eligibility Checker name = input("Enter your name: ") age = int(input("Enter your age: ")) if age >= 18: print(name + ", you are eligible to vote!") else: years_left = 18 - age print(name + ", you are not eligible to vote yet.") print("You need to wait " + str(years_left) + " more year(s).")
Understanding the Code
Code Breakdown
Testing the Program
- Run with name = Sara, age = 20 → Should print Sara, you are eligible to vote!
- Run with name = Ali, age = 15 → Should print Ali, you are not eligible to vote yet. You need to wait 3 more year(s).

Save your file with the name Voting Eligibility Checker before moving on!

.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)