divmod()
divmod(a, b)def divmod(a, b):
return a // b, a % bresult = divmod(10, 3)
print(result) # Выведет (3, 1)quotient, remainder = divmod(15, 4)
print(f"Частное: {quotient}, Остаток: {remainder}") # Выведет "Частное: 3, Остаток: 3"numbers = [10, 21, 7, 33]
for num in numbers:
quotient, remainder = divmod(num, 5)
print(f"{num} = {quotient} * 5 + {remainder}")
# Выведет:
# 10 = 2 * 5 + 0
# 21 = 4 * 5 + 1
# 7 = 1 * 5 + 2
# 33 = 6 * 5 + 3total_seconds = 3723
hours, remainder = divmod(total_seconds, 3600)
minutes, seconds = divmod(remainder, 60)
print(f"{hours:02d}:{minutes:02d}:{seconds:02d}") # Выведет "01:02:03"Последнее обновление