-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.py
More file actions
36 lines (33 loc) · 902 Bytes
/
4.py
File metadata and controls
36 lines (33 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/7/28 14:35
# @Author : Patrick.hu
# @Site :
# @File : 4.py
# @Software: PyCharm
# 输入某年某月某日,判断这一天是这一年的第几天?
m_list = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
leap = 0
year = int(input('year:'))
month = int(input('month:'))
if year < 0:
print("Error Data")
year = int(input('year:'))
else:
if year % 4 == 0 and year % 100 != 0 and month > 2:
leap = 1
elif year % 400 == 0 and month > 2:
leap = 1
if month < 1 or month > 12:
print("Error Data")
month = int(input('month:'))
day = int(input('day:'))
if day > m_list[month - 1] + leap:
print("Error Data")
day = int(input('day:'))
else:
while month > 1:
day += m_list[month - 1]
month -= 1
day += leap
print(day)