Explore

Close
Python Programs Share

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

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

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 Program To Check Voting Eligibility


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

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

Above is the python program to check whether a candidate is eligible to vote or not. 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.

To run this python program, follow the below steps:

  • Create a new folder for this python project.
  • Open it in a code editor of your choice.
  • Create a python file with an ending .py extension.
  • Copy the above code and paste it in your file.
  • Open a terminal or CMD at folder location
  • And type this command python filename.py (Name of your file).

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. Don’t want to create all the files and folders then you can run this program now using this online python compiler.

Summary

This was a simple python program to check whether a person is eligible to vote or not, 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 🙂