Objective:
Find whether the given year is a leap year.
Analysis:
It is a leap year if any one of the following two points is met:
A: It can be evenly divisible by 4, but not evenly divisible by 100;
B : Divisible by 400.
Code example:
year = int(input('请输入一个年份:')) if year % 4 == 0 and year % 100 != 0: print('闰年') elif year % 400 == 0: print('闰年') else: print('平年')
Recommended tutorial: python tutorial
The above is the detailed content of How to determine whether a certain year is a leap year in python. For more information, please follow other related articles on the PHP Chinese website!