投票 python_Python | 输入年龄并检查投票资格

投票 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值