当前位置:网站首页>Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?
Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?
2022-07-05 08:22:00 【Lazy smile】
example 004: The day after that
subject : Enter the date of the year , Judge the day as the day of the year ?
Program analysis : Calculate the day of the year , First of all, we have to calculate the total number of days in the months before this month , Add the date of the month . The sum of days in the previous months , except 2 The month is when the year is leap year 29 God , In ordinary years, it is 28 outer space , The number of days in each month is fixed , So we can set a list of days in a month , When the entered year is a leap year, put it in the list 2 The number of days in the month is changed to 29 God .
# example 004: The day after that
# ** subject :** Enter the date of the year , Judge the day as the day of the year ?
# Used to judge whether the year is a leap year
def isLeapYear(y):
return (y % 400 == 0 or (y % 4 == 0 and y % 100 != 0))
# Definition 1-11 Days of each month
DofM = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
res = 0 # Calculate the day
# Enter the date of the year
year = int(input('Year:'))
month = int(input('Month:'))
day = int(input('day:'))
if isLeapYear(year): # If it's a leap year be 2 Month for 29 God
DofM[2] = 29
for i in range(month): # Calculation month Total previous days
res += DofM[i]
# The day of the year yes month Total previous days + The number of days in this month day
print(res + day)give the result as follows :

边栏推荐
- Stablq of linked list
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- Slist of linked list
- Various types of questions judged by prime numbers within 100 (C language)
- Problem solving: interpreter error: no file or directory
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
- Let's briefly talk about the chips commonly used in mobile phones - OVP chips
- Live555 push RTSP audio and video stream summary (I) cross compilation
- WiFi wpa_ Detailed description of supplicant hostpad interface
- 实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
猜你喜欢

Some thoughts on extracting perspectives from ealfa and Ebeta

Drive LED -- GPIO control
![[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code](/img/58/576b6b77509ed7a9bef138f3899e37.jpg)
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code

STM32 --- NVIC interrupt

My-basic application 2: my-basic installation and operation
![Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine](/img/13/22a1915329f58acd54c40176f6f301.jpg)
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
![[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement](/img/54/78e4e10724b2762274b06debb10877.jpg)
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement

STM32 virtualization environment of QEMU
![Measurement fitting based on Halcon learning [i] fuse Hdev routine](/img/91/34c92065e797c87d6ce5ea13903993.jpg)
Measurement fitting based on Halcon learning [i] fuse Hdev routine

Shell script
随机推荐
Semiconductor devices (III) FET
MySQL之MHA高可用集群
Some tips for using source insight (solve the problem of selecting all)
Imx6ull bare metal development learning 2- use C language to light LED indicator
实例010:给人看的时间
Zero length array in GNU C
leetcode - 445. 两数相加 II
剑指 Offer 05. 替换空格
Shape template matching based on Halcon learning [9] PM_ multiple_ dxf_ models. Hdev routine -- [read and write XLD from DXF file]
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
Basic embedded concepts
Bootloader implementation of PIC MCU
Solutions to compilation warnings in Quartus II
STM32 single chip microcomputer -- debug in keil5 cannot enter the main function
Wifi-802.11 negotiation rate table
Installation and use of libjpeg and ligpng
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
Negative pressure generation of buck-boost circuit
Several important parameters of LDO circuit design and type selection
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream