IDNLearn.com provides a platform for sharing and gaining valuable knowledge. Get accurate and detailed answers to your questions from our knowledgeable and dedicated community members.
Sagot :
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.
We appreciate your presence here. Keep sharing knowledge and helping others find the answers they need. This community is the perfect place to learn together. Your search for answers ends at IDNLearn.com. Thanks for visiting, and we look forward to helping you again soon.