In this example we will show how to check whether a given year is Leap year in Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
year = int(input("Enter the year to be checked: "))
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print("The year is a leap year!")
else:
print("The year isn't a leap year!")
Output:
Enter the year to be checked: 1998
The year isn't a leap year!
Enter the year to be checked: 2000
The year is a leap year!
Enter the year to be checked: 2020
The year is a leap year!