Hello everyone, welcome to nkcoderz.com. In this article we will going to discuss about Program to find the given year is a leap year using Python.
To determine whether a given year is a leap year in Python, you can use the following code:
Program to find the given year is a leap year using Python
def is_leap_year(year):
if year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False
This function takes a year as input and returns a Boolean value indicating whether the year is a leap year.
Python Program to find the roots of the quadratic equation with its value
A year is a leap year if it is divisible by 4, except for years that are divisible by 100 but not by 400. For example, 2000 is a leap year, but 1900 is not.
Here’s an example of how you could use this function:
year = 2020
print(is_leap_year(year))
This code would output “True” because 2020 is a leap year.
Output
True
Conclusion
If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.