美文网首页
Python Challenge[15]

Python Challenge[15]

作者: Recgat | 来源:发表于2017-02-11 19:21 被阅读0次

[Level 15]


Title: whom?

源码中有两处注释:

  1. he ain't the youngest, he is the second
  2. todo: buy flowers for tomorrow

图片中年份被划掉了。如果能注意到右下角显示的二月有29天,那么思路就清晰了。还应注意到日期对应的星期。

import datetime
year = [i for i in range(1006,1997,10)]
for i in year:
  if (i%100==0 and i%4==0) or (i%4==0 and i%100!=0):
    date = datetime.date(i,1,26)
    if date.weekday()==0:
      print(i)

五个年份,提示又是第二年轻,所以是1756。又是tomorrow,所以是1756年1月27日。搜索可知道莫扎特(Mozart)的生日正是这个,[Level 16]

小结

  1. date.weekday()将星期作为数字返回,星期一为0,星期天为6。date.isoweekday()功能相同,但是星期一为1,星期天为7。

Python Challenge Wiki

判断闰年可以更简洁。calendar.isleap(year)直接判断是否闰年。

More

相关文章

  • Python Challenge[15]

    [Level 15] Title: whom? 源码中有两处注释: he ain't the youngest, ...

  • Python挑战:00~03关

    Python Challenge Python Challenge 00 网址: http://www.pytho...

  • Python挑战:04-05关

    Python Challenge Python Challenge 04 现在,我们来挑战第四关,从第三关的结果,...

  • The Python Challenge(5)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: 再点击页面图片显示: 可知是需要...

  • The Python Challenge(8)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 页面和源码中无任何提示,但图片中有一条很明显的灰度线...

  • The Python Challenge(9)

    问题链接 问题链接如下: 答案链接 答案链接如下: 登陆用户名密码为huge和file。 解题思路 阅读源码有如下...

  • The Python Challenge(2)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 将页面给定的字符串根据给定规则进行替换即可,规则如下...

  • The Python Challenge(3)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 阅读源码,有如下内容: 编写代码从中...

  • The Python Challenge(4)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 并结合页面源码中的内容,有如下代码:...

  • The Python Challenge(6)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: python中发音类似的术语有p...

网友评论

      本文标题:Python Challenge[15]

      本文链接:https://www.haomeiwen.com/subject/xvowittx.html