Find the date after next half year from a given date | Function to find the date after the next half - year ; Stores the number of days in the months of a leap year ; List of months ; Days in half of a year ; Index of current month ; Starting day ; Decrement the value of cnt by 1 ; Increment cur_date ; If cnt is equal to 0 , then break out of the loop ; Update cur_month ; Update cur_date ; Print the resultant date ; Driver Code ; Function Call
def getDate ( d , m ) : NEW_LINE INDENT days = [ 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] NEW_LINE month = [ ' January ' , ' February ' , ' March ' , ' April ' , ' May ' , ' June ' , ' July ' , ' August ' , ' September ' , ' October ' , ' November ' , ' December ' ] NEW_LINE cnt = 183 NEW_LINE cur_month = month . index ( m ) NEW_LINE cur_date = d NEW_LINE while ( 1 ) : NEW_LINE INDENT while ( cnt > 0 and cur_date <= days [ cur_month ] ) : NEW_LINE INDENT cnt -= 1 NEW_LINE cur_date += 1 NEW_LINE DEDENT if ( cnt == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT cur_month = ( cur_month + 1 ) % 12 NEW_LINE cur_date = 1 NEW_LINE DEDENT print ( cur_date , month [ cur_month ] ) NEW_LINE DEDENT D = 15 NEW_LINE M = " January " NEW_LINE getDate ( D , M ) NEW_LINE