可愛的python习题答案.docVIP

  • 23
  • 0
  • 约3.43万字
  • 约 42页
  • 2016-12-05 发布于重庆
  • 举报
可愛的python习题答案

可爱的python习题答案 ?status 校对 lizzie 完成度100% CDays-5 计算今年是闰年嘛?判断闰年条件, 满足年份模400为0, 或者模4为0但模100不为0. 源代码 Toggle line numbers 1 #coding:utf-8 2 cdays-5-exercise-1.py 判断今年是否是闰年 3 @note: 使用了import, time模块, 逻辑分支, 字串格式化等 4 5 6 import time #导入time模块 7 thisyear = time.localtime()[0] #获取当前年份 8 if thisyear % 400 == 0 or thisyear % 4 ==0 and thisyear % 100 0: #判断闰年条件, 满足模400为0, 或者模4为0但模100不为0 9 print this year %s is a leap year % thisyear 10 else: 11 print this year %s is not a leap year % thisyear 12 运行截屏 利用p

文档评论(0)

1亿VIP精品文档

相关文档