Answer to Question #329086 in Python for ratul

Question #329086

Write a function which will take 1 argument, number of days.

Your first task is to take the number of days as user input and pass the value to the function.

Your second task is to implement the function and calculate the total number of years, number

of months, and the remaining number of days as output. No need to return any value, print

inside the function.

Note: Assume, each year to be 365 days and month to be 30 days.

Hint(1): Divide and mod the main input to get the desired output.

Hint(2): This task’s calculation is similar to Assignment-1’s seconds to hours, minutes

conversion.

Example01

Input:

4330

Function Call:

function_name(4330)

Output:

11 years, 10 months and 15 days

===================================================================

Example02

Input:

2250

Function Call:

function_name(2250)

Output:

6 years, 2 months and 0 days


1
Expert's answer
2022-04-17T07:41:27-0400
def ConvertDays(number):
    years = number // 365
    months = (number % 365) // 30
    days = (number % 365) % 30
    print(f'Output:\n{years} years, {months} months and {days} days')  
    return

ConvertDays(int(input("Input number of days: ")))

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS