Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Get immediate and reliable solutions to your questions from a knowledgeable community of professionals on our platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

A year with 366 days is called a leap year. A year is a leap year if it is divisible by four (for example, 1980), except that it is not a leap year if it is divisible by 100 (for example, 1900); however, it is a leap year if it is divisible by 400 (for example, 2000). There were no exceptions before the introduction of the Gregorian calendar on October 15, 1582 (1500 was a leap year). Write a program that asks the user for a year and computes whether that year is a leap year.

Sagot :

fichoh

Answer:

def year_type(yr):

if yr%400 == 0:

print('year', yr, ':' , 'is a leap year')

elif yr%100 ==0:

print('year' , yr, ':' , 'is not a leap year')

elif yr%4 ==0:

print('year', yr, ':', 'is a leap year')

else:

print('year', yr, ':', 'is not a leap year')

year_type(int(input('Enter a year value :')))

Explanation:

The function year_type was defined and takes in one argument which is the year value.

It check if the year is a leap year or not by using the conditional of statement.

If year is divisible by 400 program prints a leap year

If year is divisible by 100 program prints not a leap year

If year is divisible by 4 ; program prints a leap year

Else; everything outside the stated conditions, program prints not a leap year.

The function is called and the argument is supplied by the user using the input method.