All Python Tutorial Links

Check whether a year is a leap year or not using Python

Check whether a year is a leap year or not using Python

Hello Programmers!

In this tutorial, you will learn how to check that a year is a leap year or not using python. This is basic project of python. If you have any questions then commentb below. So let's get started.

Code:

year = int(input("Year"))
if(year % 4 == 0):
print("Leap year")
else:
print("no")

Output:

Year: 2020
Leap year

Step-1: Create a python file

First of all, create a python file.


Step-2: Take input from the user

year = int(input("Year: "))

In the above code, we are taking input from the user as an integer.


Step-3: Add a logical statement

if(year % 4 == 0):
print("It is a leap year!")
else:
print("It is not a leap year!)

In the above code, we have added a logical statement to check whether the year is a leap year or not. We are dividing the year by 4 and if the remainder equals 0 then it will print "It is a leap year" else it will print "It is not a leap year". 

Congratulation! Now you know how to write a program to check whether it is a leap year or not. If you have any questions then you can comment below.

Happy Coding :)


leap year,python program to check leap year,leap year program,check leap year,leap year program in python,how to check whether a year is leap year or not,python program to check leap year using function,how to find whether a year is leap year or not,wap to find a whether a year is leap year or not,program to find a whether a year is leap year or not,python program to check whether leap year or not,how to find a year is leap or not in python,find a year is leap year or not

Comments