Detecting Leap Year in Python

When determining whether a year is a leap year using mathematical methods, several operations must be performed sequentially, which is not very convenient. However, Python has the ability to significantly simplify this process using a special method isleap of the calendar module. The desired year is passed to the method parameter. The method returns Boolean values. If the year is a leap year, True is output, otherwise - False.

First, you need to import the calendar module:

pythonimport calendar

Next, we apply the isleap method to the imported module. We write the result to the res variable and display it on the screen:

pythonres = calendar.isleap(2025)
print(res) # False
Задание 1

Given year:

pythonyear = 2020

Determine if it is a leap year.

Задание 2

Given year:

pythonyear = 1910

Determine if it is a leap year.

Задание 3

Determine whether the current year is a leap year.