Deviopath › Python

Minutes to h:mm

Easy · Numbers

// is integer division (it drops the fraction) and % is the remainder. So 135 // 60 is 2 and 135 % 60 is 15. In an f-string, {m:02d} pads a number with a leading zero to 2 digits.

Write a function to_clock(minutes) that turns a number of minutes into an "h:mm" string. Hours are not wrapped at 24.

Next: Letter Grade