Integer division not producing expected results
The question I attempted to answer is as follows: Write a Python function that computes the number of days, hours, and minutes in a given number of minutes
ie: def daysHoursMinutes(m)
: which ends as returns (d, h, M)
I wrote the following code:
def daysHoursMinutes(m):
import math
d=m/1440 #integer
h=m/60 #integer
M=m #integer
return(d,h,M)
and when I input in daysHoursMinutes(241)
what im expecting to get is (0,4,1)
, but I get ((0.1673611111111111, 4.016666666666667, 241)
. I'm confused as to what I'm doing wrong??
1 answer

Integer division in Python3 uses
//
like:Code:
def daysHoursMinutes(m): d = m // 1440 m = d * 1440 h = m // 60 m = h * 60 return d, h, m
Test Code:
print(daysHoursMinutes(241))
Results:
(0, 4, 1)