Minutes to Hours and Minutes
Programming Basics · Python
TASK
Problem
Given non-negative minutes `m`, print full hours and remaining minutes separated by a space.
EXAMPLE
Example
135
2 15
LIMITS
Constraints
Quantities, prices, and balances are integers from 0 to 10^9; other integer inputs have absolute value at most 10^9.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `int()` converts a numeric string into an integer. The `//` operator performs integer division and keeps the whole-number part. The `%` operator returns the remainder after division. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** The `//` and `%` operators complement each other: the first gives the integer quotient and the second gives the remainder. This is useful when splitting a number into groups or digits. The expression `m // 60` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Hours are `m // 60`; remaining minutes are `m % 60`.']
ANSWER
Solution
+
m = int(input()) print(m // 60, m % 60)