基于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    # 每轮一天即将天数计数变量加一

 

转载于:https://www.cnblogs.com/maoguy/p/5943211.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值