Knowee
Questions
Features
Study Tools

Program to check if a person can vote

Question

Program to check if a person can vote

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Python program to check if a person can vote:

def can_vote(age):
    if age >= 18:
        return "You are eligible to vote."
    else:
        return "You are not eligible to vote."

# Test the function
print(can_vote(20))  # Output: You are eligible to vote.
print(can_vote(16))  # Output: You are not eligible to vote.

In this program, we define a function can_vote() that takes an age as an argument. Inside the function, we use an if-else statement to check if the age is greater than or equal to 18. If it is, the function returns "You are eligible to vote." If it's not, the function returns "You are not eligible to vote."

We then test the function with two different ages: 20 and 16. The output shows that the function correctly determines whether or not these ages are eligible to vote.

This problem has been solved

Similar Questions

Write a program to check whether a person is eligible for voting or not. (accept age from user)

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

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

list out in detail functional and non functional reuirements of online voting system

National Assembly of USA has ______ members who can vote.

1/1

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.