Back to the page

In the print window, choose “Save as PDF”.

doubtly doubtly.in

Write a program that prompts the user to input a year and determine whether the year is a leap year or not.

Python · Updated 27 Jan 2024 · Read online: www.doubtly.in/write-a-program-that-prompts-the-user-to-input-a-year-and-determine-whether-the-year-is-a-leap-year-or-not/

Write a program that prompts the user to input a year and determine whether the year is a leap year or not.

Leap Years are any year that can be evenly divided by 4. A year that is evenly divisible by 100 is a leap year only if it is also evenly divisible by 400. Example :

  1. 1992        Leap Year
  2. 2000        Leap Year
  3. 1900        NOT a Leap Year
  4. 1995        NOT a Leap Year
#program to determine leap year
yr= int(input("Enter year to determine the is it leap or not"))

if (yr%4 == 0 ) or (yr%100 != 0 and yr%400 == 0) :

    print("The year is a leap year!")
else:
    print("The year isn't a leap year!")

Practise this on Doubtly (free)