Todos Novo

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Entrar


Todos Novo Entrar

All gists matching topic beginner-friendly

Mais recente criado
Menos recente criado
Mais recente atualizado
Menos recente atualizado

timmy / 📆 閏年還是平年?一行 Python 判斷超直覺!

0 curtidas
0 bifurcações
1 arquivos
Última atividade 8 months ago
用最簡單的邏輯搞懂閏年判斷:被 4 整除但不能被 100 整除,或被 400 整除就對了 ✅
beginner-friendly date-utils datetime leap-year python simple-script
1 def is_leap_year(year):
2 return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
3
4
5 # 調用 is_leap_year 函數來判斷特定年份是否為閏年
6 year = 2024 # 請更改為您想要檢查的年份
7 if is_leap_year(year):
8 print(f"{year} 年是閏年")
9 else:
10 print(f"{year} 年不是閏年")
Próximo Anterior

Desenvolvido por Opengist ⋅ Load: 14ms⋅

Português
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文