python逻辑判断

本文探讨了如何使用Python进行逻辑判断,包括如何判断一个年份是否为润年,以及计算一年中的第几天。通过对年份的数学运算和日期处理,深入理解Python的条件语句和日期模块。
摘要由CSDN通过智能技术生成

1、判断是否为润年

Year=int(input("please input year:"))
Mouth=int(input("please input mouth:"))
if (Year % 4 == 0 and Year % 100 != 0 or Year % 40 == 0):
    if (Mouth == 2):
        print("29 days")
    elif (Mouth == 1 or Mouth ==3 or Mouth ==5 or Mouth ==7 or Mouth ==8 or Mouth ==10 or Mouth ==12):
          print("31 days")
    else:
        print("30 days")
else:
    if (Mouth == 2 ):
        print("28 days")
    elif (Mouth == 1 or Mouth ==3 or Mouth ==5 or Mouth ==7 or Mouth ==8 or Mouth ==10 or Mouth ==12):
        print("31 days")
    else:
        print("30 days")

2、判断一年中的第几天

Year=int(input("please input year:"))
Mouth=int(input("please input mouth:"))
Day=int(input("please input day:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值