寫代碼:輸入一年份,判斷該年份是否是閏年並輸出結果。


# 輸入一年份,判斷該年份是否是閏年並輸出結果。
# 注: 凡符合下面兩個條件之一的年份是閏年。
# 1. 能被4整除但不能被100整除。
# 2. 能被400整除。

year = int(input("please enter the year: "))

if year % 4 == 0 and year % 100 > 0:
print("The %s is leap year" % year)
elif year % 400 == 0:
print("The %s is leap year" % year)
else:
print("The %s is NOT leap year" % year)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM