Home »
Python »
Python programs
Python | Input age and check eligibility for voting
Python | if else example: Here, we are implementing a program, it will read age from the user and check whether person is eligible for voting or not.
Submitted by Pankaj Singh, on September 29, 2018
Input age of the person and check whether a person is eligible for voting or not in Python.
This is a simple if else example in the python - Here, we will read the age of the person by using input() function and convert the entered age value to the integer by using int() function. Then we will check the condition, whether age is greater than or equal to 18 or not - if age is greater than or equal to 18, the person will be eligible for the voting.
Program:
# input age
age = int(input("Enter Age : "))
# condition to check voting eligibility
if age>=18:
status="Eligible"
else:
status="Not Eligible"
print("You are ",status," for Vote.")
Output
Enter Age : 19
You are Eligible for Vote.
Python Basic Programs »
ADVERTISEMENT
ADVERTISEMENT