- 1

Leap year

A year is a leap year if it is divisible by 4, except it is divisible by 100, but it is a leap year when it is divisible by 400.Write a program that asks the user for a year and prints out if the year is a leap year or not

11th May 2020, 12:54 AM
Adeniyi Olaitan
Adeniyi Olaitan - avatar
3 Antworten
+ 6
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): print("leap year") else: print("not a leap year")
11th May 2020, 1:04 AM
ChaoticDawg
ChaoticDawg - avatar
0
That's correct
11th May 2020, 1:09 AM
Adeniyi Olaitan
Adeniyi Olaitan - avatar
0
year = int(input()) if(year%4 == 0): if(year%100 == 0): if(year%400 == 0): print("Leap year") else: print("Not a leap year") else: print("Leap year") else: print ("Not a leap year")
2nd Jan 2022, 7:53 AM
Roaa Qteishat
Roaa Qteishat - avatar