Q. Write a program to take year as input and check if it is leap year or not.


You can understand by Watching video :-



Answer :-

year = int(input("Enter year = "))
print((year % 4 == 0  and "it is leap year ")or "it is not leap year")

Output :-

Enter year = 2020
it is leap year

>>> 

Enter year = 2022
it is not leap year

>>> 

Enter year = 2016
it is leap year

>>>

1 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. HEMAPRIYA NATARAJ KUMAR1 October 2024 at 17:07

    this leap year program is wrong
    year = int(input("Enter year = "))
    if year % 400 = = 0:
    A=True
    elif year % 100 = = 0:
    A=False
    elif year % 4 == 0:
    A=True
    else:
    A=False
    if A= =True:
    print("the ",year," is a leap year")
    else:
    print("the ",year," is not a leap year")

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post