Computer Science
A year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years unless they are also divisible by 400. Write a program that asks the user for a year and prints out whether it is a leap year or not.
Answer
year = int(input("Enter year: "))
if year % 400 == 0 :
print(year, "is a Leap Year")
elif year % 100 == 0 :
print(year, "is not a Leap Year")
elif year % 4 == 0 :
print(year, "is a Leap Year")
else :
print(year, "is not a Leap Year")
Output
Enter year: 1800
1800 is not a Leap Year
Related Questions
Write a program to input length of three sides of a triangle. Then check if these sides will form a triangle or not.
(Rule is: a+b>c;b+c>a;c+a>b)Write a program that asks the user for two numbers and prints Close if the numbers are within .001 of each other and Not close otherwise.
Write a program that reads from user — (i) an hour between 1 to 12 and (ii) number of hours ahead. The program should then print the time after those many hours, e.g.,
Enter hour between 1-12 : 9
How many hours ahead : 4
Time at that time would be : 1 O'clockWrite a short program to input a digit and print it in words.