Write a python program to generate the next 15 leap years starting from a given year. Populate the leap years into a list and display the list.
Answers
Answer:
def find_leap_years(given_year):
count=0
list_of_leap_years=[]
while(count<15):
if(given_year%4==0 or given_year%400==0 and given_year%100==0):
list_of_leap_years.append(given_year)
count=count+1
given_year=given_year+1
return list_of_leap_years
list_of_leap_years=find_leap_years(2000)
print(list_of_leap_years)
Step-by-step explanation:
Starting from the given year,check whether every year is leap year or not.If you found the year to be leapyear ,then increase your count.If required count i.e., 15 here,is reached then you may stop.
Answer:
def find_leap_years(given_year):
count=0
list_of_leap_years=[]
while(count<15):
if(given_year%4==0 or given_year%400==0 and given_year%100==0):
list_of_leap_years.append(given_year)
count=count+1
given_year+=4
else:
given_year+=1
return list_of_leap_years
Step-by-step explanation:
here we dont know the user input it may be leap year or not so if user enters a leap year the we incerase by +4 if not we incerase year by 1 util it is leap year then folloed by +4