Python program to check leap year; Through this tutorial, i am going to show you how to check leap year in python.
In this tutorial, i will write two program to check leap year in python.
Python Program to Check Leap Year
- Python program to check whether a given year is a leap year or not
- Python program to check leap year using function
Python program to check whether a given year is a leap year or not
# Python program to check the given year is leap or not n = input("Please enter year") year = int (n) if (( year%400 == 0)or (( year%4 == 0 ) and ( year%100 != 0))): print("%d is a Leap Year" %year) else: print("%d is Not the Leap Year" %year)
Output
Please enter year 2021 2021 is Not the Leap Year
2: Python program to check leap year using function
# Python program to check the given year is leap or not # using math calender module in Python #here import calender module import calendar n = input("Please enter year") year = int (n) # calling isleap() method to check for Leap Year val = calendar.isleap(year) if val == True: print("% s is a Leap Year" % year) else: print("% s is not a Leap Year" % year)
Output
Please enter year 2019 2019 is not a Leap Year
Recommended Python Tutorials
Recommended:-Python Program to Add Two Numbers
Recommended:-Python Program to Calculate Simple Interest
Recommended:-Python Program to Find Average of n Numbers
Recommended:-Python Program to ASCII Value of Character
Recommended:-Python Concatenate String and Variable (int float)
Recommended:-Python Trim String – rstrip(), lstrip(), strip()
Recommended:-Python Dictionary Methods with Example
Recommended:-Python Reverse String
Recommended:-Python String find() Method
Recommended:-Python Replace Character in String
Recommended:-Python Convert String to Float
Recommended:-Python String translate() Method Example
Recommended:-Python Convert String to List
Recommended:-Python filter() Method
Recommended:-Python Map() Method