Python: Find the Number of Years

less than 1 minute read

The code has been modified slightly and now uploaded to the site.

The questions are from the C++ Textbook.

Question

<— Return Home

27.py

import math

num = int(input("Enter the number of minutes: "))
to_year = 24 * 60 * 365
new_num = num / to_year
to_month = new_num - math.trunc(new_num)
to_month *= 365
# print(math.trunc(new_num))
# print(math.trunc(to_month))
print(str(num) + " minutes is approximately " + str(math.trunc(new_num)) + " years and " + str(math.trunc(to_month)) + " days")

<— Return Home