Computer Science, asked by nehrayash71, 3 months ago

Write a Program in Python to Find Year in Leap Year or Not.​

Answers

Answered by anindyaadhikari13
2

Answer:

The given program is written in Python.

def year(n):

if len(str(n))!=4:

print("Invalid Input.")

else:

if n%4==0:

if n%100==0:

if n%400==0:

print(f"{n} is a leap year.")

else:

print(f"{n} is not a leap year.")

else:

print(f"{n} is a leap year.")

else:

print(f"{n} is not a leap year.")

# Main Códe

while True:

year(int(input("Enter Year:")))

print("Do you want to continue? (Y/N)")

x=input()[0].upper()

if x=='N':

break

Leap years are always divisible by 4. However, if the year is a century year, it must be divisible by 400 to be a leap year. Using this logic, problem is solved.

Refer to the attachment for output.

•••♪

Attachments:
Similar questions