当前位置:网站首页>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 :

边栏推荐
- C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
- 实例005:三数排序 输入三个整数x,y,z,请把这三个数由小到大输出。
- Carrier period, electrical speed, carrier period variation
- Weidongshan Internet of things learning lesson 1
- 动力电池UL2580测试项目包括哪些
- Drive LED -- GPIO control
- Soem EtherCAT source code analysis I (data type definition)
- Solutions to compilation warnings in Quartus II
- [trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
- C WinForm [help interface - send email] - practice five
猜你喜欢
![C WinForm [exit application] - practice 3](/img/25/30c795cc3fa6931eb1d733719d4ad0.jpg)
C WinForm [exit application] - practice 3
![[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication](/img/08/7f28008a4aa999650998ba8dee5d8e.jpg)
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication

Arduino uses nrf24l01+ communication

Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic

C # joint configuration with Halcon
![Measurement fitting based on Halcon learning [i] fuse Hdev routine](/img/91/34c92065e797c87d6ce5ea13903993.jpg)
Measurement fitting based on Halcon learning [i] fuse Hdev routine

Stm32--- systick timer

STM32 single chip microcomputer - bit band operation

UE像素流,来颗“减肥药”吧!
![[trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture](/img/c5/22c6148873508b9205972e1ad970a3.jpg)
[trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
随机推荐
Introduction of air gap, etc
Use indent to format code
Shape template matching based on Halcon learning [9] PM_ multiple_ dxf_ models. Hdev routine -- [read and write XLD from DXF file]
Tailq of linked list
More than 90% of hardware engineers will encounter problems when MOS tubes are burned out!
Stm32--- systick timer
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
Naming rules for FreeRTOS
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
Slist of linked list
Basic information commands and functions of kernel development
OC and OD gate circuit
MySQL MHA high availability cluster
STM32 virtualization environment of QEMU
Volatile of C language
C language # and #
Bluetooth hc-05 pairing process and precautions
实例003:完全平方数 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Semiconductor devices (III) FET