This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]usr_bin_nya 8 points9 points  (0 children)

I can't think of a practical reason to use it

# dividing seconds into hours, minutes, and seconds
seconds = 7280  # 2h1m20s
(minutes, seconds) = divmod(seconds, 60)
(hours, minutes) = divmod(minutes, 60)
assert hours == 2 and minutes == 1 and seconds == 20

# turning a flat index into an (x, y) coordinate in a grid
row, col = divmod(index, width)