Python program that asks for the user’s age and checks whether they are old enough to vote.

In this program, we use the built-in input function to ask the user for their age, and then convert the input to an integer using the int function. Next, we use an if statement to check if the user’s age is greater than or equal to 18. If it is, we print a message that the user can vote. Otherwise, we print a message saying the user is not yet old enough to vote.

Code:

# ask for the user’s age

age = int(input(“Enter your age: “))

# check if the user is old enough to vote

if age >= 18:

print(“You are eligible to vote.”)

else:

print(“Sorry, you are not yet old enough to vote.”)

By DDSRY

Hey, DDSRY is a Computer Science Student, Python Programmer, Indian Python Podcaster, and Content Creator. DDSRY Help Students To Learn Python Programming Language on Social Media. This Website (ddsry.com) is committed to helping students to Learn Python Programming Language in the easy and best way by DDSRY. @DDSRY