Python program to check if a user is eligible for voting
In this post, you will learn how to check if a user is eligible for voting or not using the Python programming language. The program will accept the age as an input from the user, check the eligibility and then print out the result.
In India, a person's age should be 18 or greater than 18 to become eligible for voting. We can simply implement this logic in an if-else conditional statement to check whether a person is eligible to vote or not.
Python program to check vote eligibility
In the given Python program, we asked the user to enter the age of the person by using the input() function. We use the int() function to convert the user's entered age value to an integer.
# Python program to check vote eligibility
age = int(input("Enter age of a user: "))
if age >= 18:
print("User is eligible for voting: ", age)
else:
print("User is not eligible for voting: ", age)
Output1:
Enter age of a user: 25
User is eligible for voting: 25
Output2:
Enter age of a user: 13
User is not eligible for voting: 13
Output3:
Enter age of a user: 18
User is eligible for voting: 18
Related Articles
Python program to convert time from 12 hour to 24 hour formatPython class method vs static method
Bootstrap datepicker example
Python datetime formats and functions
Age calculator in Python
Pandas string to datetime
Convert Excel to CSV Python Pandas
Python program to display calendar
Python newspaper - Article scraping and curation
Python compare two lists
Remove element from list Python
Countdown clock and timer using Tkinter in Python
Python program to sum all the numbers in a list
Python print without newline
Python iterate list with index
Python add list to list
Python convert xml to dict
Python dict inside list
Python convert dict to xml
Python weather api
Python raise keyword