判斷奇數偶數和閏年(Python)

int_number = int(input("請輸入整數:"))
if int_number % 2 != 0:
    print("奇數")
else:
    print("偶數")

year = int(input("請輸入年份:"))
if year % 4 == 0 and year % 100 != 0:
    print("閏年")
elif year % 400 == 0:
    print("閏年")
else:
    print("平年")

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章