投票 python
Input age of the person and check whether a person is eligible for voting or not in Python.
输入人员的年龄,并使用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.
这是一个简单的python例子-在这里,我们将使用input()函数读取人的年龄,并使用int()函数将输入的年龄值转换为整数。 然后,我们将检查条件,即年龄是否大于或等于18 岁 - 如果年龄大于或等于18岁,则该人有资格参加投票 。
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.
翻译自: https://www.includehelp.com/python/input-age-and-check-eligibility-for-voting.aspx
投票 python