Python之if判断语句

本文提供了一个Python程序示例,展示了如何使用if-elif-else条件语句来处理不同的整数输入,并根据输入值输出特定的信息。通过简单的数字判断,程序能够返回如'Negative changed to zero'、'zero'、'single'或'more'等反馈。
x =  int(input("Please ente an integer:"))
#y = float(input("Please enter a float"))

if x < 0 :
    x = 0
    print("Negative changed to zero")
elif x == 0 :
    print("zero")
    print('zero')

elif x == 1 :
      print("single")
else :
      print("more")

"""
if statements:

if   condition_one :
     statement_one
elif condition_two :
     statement_two
elif....
else statement_n
"""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值