Python Programs

Python Program To Check Whether A Person Is Eligible To Vote Or Not

Last updated June 21, 2023 by Jarvis Silva

In this tutorial we will write a python program to check whether a person is eligible to vote or not. You can also use this program to build your python voting program or system.

To create this program we will use if else statements, In India a person who is 18 and above can vote so we take that criteria as a condition and create this program.

Algorithm To Check Voting Eligibility

  • Ask the user to enter their age.
  • Check if age is greater or equal to 18
  • If the above condition is true then print eligible.
  • If the above condition is false then print not eligible.

As you can see from the above algorithm that it is very simple program so let’s see how to create it in python code.

Python Code To Check Voting Eligibility

age = int(input("Enter you age: "))

if age >= 18:
    print("You are eligible to vote")
    print("You are not eligible to vote")

Above is the python program to check whether a candidate is eligible to vote or not, we have used if statement to check if age is greater or equal to 18 then eligible to vote else not eligible to vote.

Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer or use this online python compiler.

After running this program it will ask you to enter your age and after entering it will check and print if you are eligible to vote or not below is an example output.

Enter you age: 19
You are eligible to vote

As you can see we successfully created our voting eligibility checker program in python, I hope you found this tutorial helpful and useful. Do share this tutorial with your friends who might be interested in this program.

Here are some more python program tutorials for you:

I hope you found what you were looking for from this tutorial, and if you want more python programs and tutorials like this, do join our Telegram channel for future updates.

Thanks for reading, have a nice day 🙂