Leap Year or Not Program in Python


Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||.

This program is a basic implementation of a program that checks if a given year is a leap year or not. The program first prompts the user to input a year using the "input" function, and then converts the input string to an integer using the "int" function.

A leap year is a year that is divisible by 4, except for end-of-century years which must be divisible by 400. The program uses an "if-else" statement to check if the input year is a leap year or not using this rule.

The program checks if the year is divisible by 4 and not divisible by 100 or if the year is divisible by 400. If the year is a leap year, it prints "Given Year is a leap Year" to the console. If the year is not a leap year, it prints "Given Year is not a leap Year" to the console. This program will work for any year, as it checks the leap year condition according to the standard rule.


Source Code

year = int(input("Enter the Year :")) 
if (year%4 == 0 and year%100 != 0) or (year%400 == 0):
	print("Given Year is a leap Year")
else:  
	print ("Given Year is not a leap Year")  

Output

Enter the Year :2000
Given Year is a leap Year


Example Programs