Write a program in Python programming language, which allows the user to input year value and based on the input value, the program should perform the following tasks:
Sample output for the wrong input:
Enter the year : -1995
wrong input !! year should be positive integer.
Enter the year : 19
wrong input !! worng input Enter the year in correct format i.e , 1980 or 2030
Sample output for the correct input:
Enter the year : 2020
2020 is a leap year
Enter the year : 2021
2021 is not a leap year
year = int(input("Eneter a year: "))
if year < 0:
print('wrong input !! year should be positive integer')
elif year < 1000 or year > 9999:
print('wrong input !! worng input Enter the year in correct format i.e., 1980 or 2030')
elif year%4 == 0 and (year%100 != 0 or year%400 == 0):
print(year, 'is a leap year')
else:
print(year, 'is not a leap year')
Comments
Leave a comment