Count of Leap Years in a given year range | Function to calculate the number of leap years in range of ( 1 , year ) ; Function to calculate the number of leap years in given range ; Driver Code
def calNum ( year ) : NEW_LINE INDENT return ( year // 4 ) - ( year // 100 ) + ( year // 400 ) ; NEW_LINE DEDENT def leapNum ( l , r ) : NEW_LINE INDENT l -= 1 ; NEW_LINE num1 = calNum ( r ) ; NEW_LINE num2 = calNum ( l ) ; NEW_LINE print ( num1 - num2 ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT l1 = 1 ; r1 = 400 ; NEW_LINE leapNum ( l1 , r1 ) ; NEW_LINE l2 = 400 ; r2 = 2000 ; NEW_LINE leapNum ( l2 , r2 ) ; NEW_LINE DEDENT