If Statement Example Programs


Check the given number is even or odd using if statement in python

Source Code

number =int(input("Enter a number :"))
if(number %2 == 0):
    print("The given number is Even")
else:
    print("The given number is Odd")
To download raw file Click Here

Output

Enter a number :7
The given number is Odd

Check the given year is leap year or not using if statement in python

Source Code

year =int(input("Enter a year: "))
if(year % 4 == 0):
    print("The given year is leap year")
else:
    print("The given year is not a leap year")
To download raw file Click Here

Output

Enter a year: 2002
The given year is not a leap year