Instagram
youtube
Facebook

Q) Years=[1994,1891,2010,1999,1700,1698,2004] code to count number of leap years in the list

Answer:

count=0
years=[1994,1891,2010,1999,1700,1698,2004]
for i in years:
   if(i%4==0 and i%100!=0 or i%400==0):
      count=count+1
print("Number of leap years:",count)

 

This code will count the number of leap years in the given list. A leap year is a year with an extra day, February 29th, which occurs every four years. The code will iterate through the list, checking if each year is a leap year. If it is, the code will add one to a counter. At the end, the counter will hold the total number of leap years in the list.

  • 689 Views

FAQ

Years=[1994,1891,2010,1999,1700,1698,2004] code t…

count=0
years=[1994,1891,2010,1999,1700,1698,2004]
for i in years:
   if(i%4==0 and i%100!=0 o…

ImportError: DLL load failed while importing _cex…

To solve this error you can use . This error came when i worked on matplotlib in python. This is th…

Program to swap variables in python

A program in Python that allows two variables to swap values.

def swap(x, y):

   temp = x
…