Python Program to Check a Year is Leap Year or Not

Python Program To Check a Leap Year

Hey Shouters!! Today we have come up with the Python program to check leap year.

Leap year program is a very important program for the placement point of view and from exams point of the year.

What is a Leap Year?

Leap year is a year in which there is an extra one day in the year.

In a normal year, the number of days is 365 but in a leap year we have 366 days and that is because of the distance between the earth and sun.

Leap year comes after every four years in the year count.

Logic to Check Leap Year-

In programming, it is very important to have a mathematics logic for solving the problem.

In Leap year program, we also have the logic. The logic to check a leap year is:

Condition 1: If a year is divisible by 4 and is not divisible by 100. It is called a leap year.

For example 1. 1800 is divisible by 4 but is also divisible by 100. So, 1800 is not a leap year.

Condition 2: If year is divisible by 400, year is also a leap year.

For Example, Consider 2000, the year is not able to fulfill the condition 1 but is divisible by 400, it will also be a leap year.

1. Python Program To Check leap year using If-else:

In this program, we will use Conditions statements like if-else and will find out the leap year or not.

In this method, we first check the first condition and then used the second condition using if-else and then got the result.

2. Python Program to Check Leap Year using Functions-

In this method, we will use a function Leap_Year() and will check the leap year.

If you want to prepare for placement mock tests, then follow us on Instagram, we daily add Multiple Choice Questions to clear concepts. Shout Coders

Recommended Posts –

  1. INTRODUCTION TO PANDAS IN MACHINE LEARNING
  2. INTRODUCTION TO GOOGLE COLAB
  3. THE DATA CLEANING
  4. FIRST MACHINE LEARNING MODEL

Leave a Reply

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami