This post was last Updated on June 8, 2023 by Himanshu Tyagi to reflect the accuracy and up-to-date information on the page.
In this tutorial, you will find a simple Python 3 program to check leap year. It would be best to understand this program if you understood Python variables, operators, and if-else statements.
Python Program to Check Leap Year
To check if a number is a leap year, it should follow these conditions:
1. The year should be completely divisible by 4.
2. The year should be utterly divisible by both 100 and 400.
Now, in the Python code, you can take year input from the user and see its divisibility by using nested if-else statements.
year = int(input("enter the year: ")) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: print('%0.0f is a leap year' % year) else: print('%0.0f is not a leap year' % year) else: print('%0.0f is a leap year' % year) else: print('%0.0f is not a leap year' % year)
Other Python 3 Programs:
- Python 3 Program to Generate A Random Number.
- Python 3 Program To Swap Two Numbers.
- Python 3 Program To Solve A Quadratic Equation.
- Python 3 Program to Calculate The Area of a Triangle.
- Python 3 Program to Find the Square Root of A Number.