Python

Python Program to Check Leap Year2 min read

Write a program to Check Leap Year in Python

Code:




This Python program takes an input year from the user and determines if it is a leap year or not. A leap year is a year that is divisible by 4, except for end-of-century years, which must be divisible by 400 to be leap years.

The program starts by asking the user to input a year. The input is then stored as an integer in the variable “year”.

Then, the program checks if the year is divisible by 4. If it is divisible by 4, it checks if the year is divisible by 100. If it is also divisible by 100, it checks if it is divisible by 400. If it is divisible by 400, it prints “year is a leap year” to the output, where year is the input provided by the user. If it is not divisible by 400, it prints “year is not a leap year” to the output.

If the year is not divisible by 100, the program prints “year is a leap year” to the output.

If the year is not divisible by 4, the program prints “year is not a leap year” to the output.

The output will be a string indicating whether the input year is a leap year or not.

Leave a Comment