Question #167623

Input : the input will be a single line containing a positive integer (N).

Out put : output should be a single line containing years, weeks, days values separated by spaces

N is 1329


Expert's answer

def ywd(days):
    """Split days into years, weeks, days.
        Assuming each year contains exactly 365 days.

    >>> ywd(1329)
    (3, 33, 3)
    >>> ywd(5)
    (0, 0, 5)
    >>> ywd(7)
    (0, 1, 0)
    >>> ywd(8)
    (0, 1, 1)
    >>> ywd(364)
    (0, 52, 0)
    >>> ywd(365)
    (1, 0, 0)
    >>> ywd(366)
    (1, 0, 1)
    """
    y, rest = divmod(days, 365)
    w, d = divmod(rest, 7)
    return y, w, d

# main
N = int(input('N? '))
print(*ywd(N))

if __name__ == '__main__':
    import doctest
    doctest.testmod()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS