Leap year in python with source code

Leap year in python with source code

Introduction

Leap year is a year containing an extra day. Usually, a year has 365 days. The year where February has 29 days is referred as Leap.

The leap year has 366 days. In this tutorial, we will be writing a program that checks whether the year is leap or not. It is a simple program within a few lines of code. It is coded in python programming language. Python is a high level general-purpose programming language that perform huge tasks within a few lines of codes. The code below is useful for finding the leap or not. See the code below.

Source code

is_on = True
while is_on:
  year = int(input("Which year do you want to check: "))

  if year % 4 == 0:
      if year % 100 == 0:
          if year % 400 == 0:
              print("Leap year")
          else:
              print("Not leaps year")
      else:
          print("Sorry...")
  else:
      print("Not found")

Output

leap year

One comment

Leave a Reply

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