KnowledgeBoat Logo
|

Computer Science

Write a module to input total number of days and find the total number of months and remaining days and display it in another program.

Python Modules

1 Like

Answer

# days.py
def calculate(total_days):
    months = total_days // 30
    remaining_days = total_days % 30
    return months, remaining_days
# calculate.py
from days import calculate

total_days = int(input("Enter the total number of days: "))
months, remaining_days = calculate(total_days)
print("Total number of months:", months)
print("Remaining days:", remaining_days)
Output
Enter the total number of days: 100
Total number of months:  3
Remaining days:  10

Answered By

3 Likes


Related Questions