zoukankan      html  css  js  c++  java
  • 基于Python的黑色星期五查找脚本

    找出输入年份的黑色星期五:

      用法:

        


     1 # -*-coding:utf-8-*-
     2 
     3 # Python程序设计作业,找出黑色星期五
     4 
     5 theYear = input ("Please input the year you want to konw : ")
     6 
     7 theFirstDay = input ("What day is theFirstDay (1 , 2 , 3 , 4 , 5 , 6 , 7) : ")
     8 
     9 day = 1            # 天数计数变量
    10 
    11 bigMonth = [1 , 3 , 5 , 7 , 8 , 10 , 12]
    12 smallMonth = [4 , 6 , 9 , 11]
    13 
    14 if ((theYear % 4 == 0) and (theYear % 100 != 0)) or (theYear % 400 == 0) :
    15     print u"这是闰年,二月份有29日"
    16 
    17     for theMonth in range (1 , 13) :
    18         if theMonth in bigMonth :
    19             for theDay in range (1 , 32) :
    20                 if (theDay == 13) and (day % 7 == 5) :
    21                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    22                 day = day + 1    # 每轮一天即将天数计数变量加一  
    23         elif theMonth in smallMonth :
    24             for theDay in range (1 , 31) :
    25                 if (theDay == 13) and (day % 7 == 5) :
    26                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    27                 day = day + 1    # 每轮一天即将天数计数变量加一
    28         else :
    29              for theDay in range (1 , 30) :
    30                  if (theDay == 13) and (day % 7 == 5) :
    31                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    32                  day = day + 1    # 每轮一天即将天数计数变量加一
    33 
    34 else :
    35     print u"这是平年,二月份有28日"
    36 
    37     for theMonth in range (1 , 13) :
    38         if theMonth in bigMonth :
    39             for theDay in range (1 , 32) :
    40                 if (theDay == 13) and (day % 7 == 5) :
    41                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    42                 day = day + 1    # 每轮一天即将天数计数变量加一  
    43         elif theMonth in smallMonth :
    44             for theDay in range (1 , 31) :
    45                 if (theDay == 13) and (day % 7 == 5) :
    46                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    47                 day = day + 1    # 每轮一天即将天数计数变量加一
    48         else :
    49              for theDay in range (1 , 29) :
    50                  if (theDay == 13) and (day % 7 == 5) :
    51                     print "The day is black Friday : %d / %d / %d " %(theYear , theMonth , theDay) 
    52                  day = day + 1    # 每轮一天即将天数计数变量加一
  • 相关阅读:
    【转】PowerDesigner数据库视图同时显示Code和Name
    [转]BT原理分析
    异常机制及throw与throws的区别(转)
    BS与CS的联系与区别。
    ASP.NET和C#的区别/
    上百例Silverlight网站及演示汇总,供友参考
    Bing Maps进阶系列九:使用MapCruncher进行地图切片并集成进Bing Maps
    【Silverlight】Bing Maps学习系列(八):使用Bing Maps Silverlight Control加载自己部署的Google Maps
    学习MAP 地图好地址
    Bing必应地图中国API
  • 原文地址:https://www.cnblogs.com/maoguy/p/5943211.html
Copyright © 2011-2022 走看看