mercredi 13 mai 2020

if else not working properly in functions in python program in creating leap year program

def is_leap(year):
    if year % 4 == 0:
        print("year is a leap year")
    elif year % 400 == 0:
        print("year is a leap year")
    elif year % 100 == 0:
        print("not a leap year")
    else:
        ("Not a leap year")

is_leap(2019)
  1. here i have entered the year 2019 which is not leap year but my program is not giving me out put of that if you enter a non leap year it want give out put as not a leap year.
  2. if there is any type of mistake in my program regarding any thing please tell me.
  3. this are considerations in bellow points using which i created the program -->
  4. The year must be evenly divisible by 4;
  5. If the year can also be evenly divided by 100, it is not a leap year; unless...
  6. The year is also evenly divisible by 400. Then it is a leap year.

Aucun commentaire:

Enregistrer un commentaire