Write a program to check whether a person is eligible for voting or not. (accept age from user)
Question
Write a program to check whether a person is eligible for voting or not. (accept age from user)
Solution
Sure, here is a simple Python program that checks if a person is eligible to vote based on their age:
# Step 1: Get the age from the user
age = int(input("Please enter your age: "))
# Step 2: Check if the age is greater than or equal to 18
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
This program works by first asking the user to input their age. It then checks if the age is 18 or more. If it is, it prints a message saying the user is eligible to vote. If it's not, it prints a message saying the user is not eligible to vote.
Similar Questions
Program to check if a person can vote
This script checks whether a person is eligible for voting or not. Which variable is most appropriate for line 2?1 age=int(input("Enter your age"))2 if ___ >=18:3 print("_____ for voting")4 ____:5 print("not eligible for voting")agevotenameprint
Problem StatementBuild a program for a small town where individuals are eligible to vote only if they are 18 years or older. Take the age of a person as input and indicate their eligibility. If the age is 18 or above, print "Eligible for Voting"; otherwise, print "Not eligible for Voting" using the ternary operator.Input format :The input is an integer n, representing the age of the person.Output format :The output displays either "Eligible for Voting" or "Not eligible for Voting" based on age.Refer to the sample output for formatting specifications.Code constraints :In the given scenario, the test cases will fall under the following constraints:1 ≤ n ≤ 100Sample test cases :Input 1 :18Output 1 :Eligible for VotingInput 2 :37Output 2 :Eligible for VotingInput 3 :12Output 3 :Not eligible for VotingInput 4 :9Output 4 :Not eligible for Voting
Develop a base class called Person with attributes like name, age, and gender. Derive a Voter class from Person, which extends its functionalities with attributes such as voter_id and hasVoted (a Boolean indicating whether the voter has cast their vote). Extend Person with a Candidate class, which introduces attributes like candidate_id and numVotes (representing the number of votes the candidate has received). Implement the described scenario in C++ using appropriate classes and methods to display the count of registered voters and the tally of votes cast.Test Case_1:Input:2Mr.Santhosh 18 MaleVID_101 YesCID_20CSE101 2Mr.Kavin 21 MaleVID_102 YesCID_20CSE102 1Output:number of voters registered: 2
Create a function of name check_age(). The function will receive age of a child. If the age is less than 6, then the function return “Invalid age”. If the age is less than 9, then the function return “This age is eligible for primary school”. If the age is greater than or equal to 9, then the function return “This age is not eligible for primary school”.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.