In: Computer Science
Write a Python code that will ask a user to input a year and return "Leap Year" if the year is a leap year, or "No Leap Year" if it is not a leap year. The program then asks for another year and performs the same task in the form of a loop, until the user inputs the then integer "-1." At that point, the program will exit the loop.
Program:
while(True):
year=int(input("\nEnter a year: "))
if(year==-1):
break
if(year%4==0):
if(year%100==0):
if(year%400==0):
print("Leap Year")
else:
print("No Leap Year")
else:
print("Leap
Year")
else:
print("No Leap Year")
Program Screenshot:
Output: