LEAP YEAR PROGRAM IN PYTHON

Leap Year Program in Python

Leap Year Program in Python

Blog Article

To check for a leap year in Python, use this logic:





  • Divisible by 4




  • Not divisible by 100 unless also divisible by 400





python



year = 2024
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("Leap Year")
else:
print("Not a Leap Year")

This simple yet classic problem helps beginners practice conditional logic and understand control flow in Python.




Report this page