通常情況下,一個年份是否為閏年是根據以下規則來判斷的:
1. 能被4整除的年份是閏年(如2004年、2008年、2012年);
2. 被100整除但不能被400整除的年份不是閏年(如1900年);
3. 被400整除的年份是閏年(如2000年)。
因此,可以通過以下代碼來判斷一個年份是否為閏年:
```python
def is_leap_year(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
```
如果返回值為True,則表示是閏年;如果返回值為False,則表示是平年。