Leap Year Program in Python Using If Else

Leap year or not in python. Program in Python whether it’s a leap year or not. This software determines whether or not the year is a leap year. It will print the year in python for beginners, which is executed by the value. a year of 366 days and an intercalary day on February 29th that occurs every four years.

If Else to Execute Leap Year or Not in Python

The if statement is a decision-making structure made up of an expression followed by one or more assertions. The if else structure is a decision-making structure in which the if statement is followed by an optional else statement that runs if the expression is false.

If not, then A Python statement determines whether or not an expression is true or false. The “if” statement is executed if a condition is met. Otherwise, the “otherwise” phrase takes effect. Python if else statements allow programmers to regulate the flow of their code. 

A Python if statement determines if a condition is true or false. If a particular condition is true, the statement will run a block of code. Otherwise, the block of code included within the if statement is skipped. Let’s develop a software to print the cost of a sandwich order.

year = 1998
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("{0} is leap year".format(year))
else:
print("{0} is not leap year".format(year))
else:
print("{0} is leap year".format(year))
else:
print("{0} is not leap year".format(year))

Output

1998 is not leap year