Novice · Arithmetic · 32 of 264
Pizza slices
Some pizza slices are shared equally. Print how many slices each person gets, and how many are left over.
Input: the number of slices and the number of people, one per line. Output: Each gets <n> on the first line, Left over: <m> on the second.
Examples
Input
16 5
Output
Each gets 3 Left over: 1
Input
8 4
Output
Each gets 2 Left over: 0
Input
3 6
Output
Each gets 0 Left over: 3
One more test checks other inputs when you press Check.
Stuck? The idea behind arithmetic
input() always gives text: turn it into a whole number with int() or a decimal with float() before doing sums.
+ - * / work as in maths; / always gives a decimal. // divides and drops the remainder, % gives the remainder, ** raises to a power.
a = int(input()) b = int(input()) print(a + b) print(a // b, a % b)
Watch for: "5" + "3" is "53", not 8: if a sum joins numbers together, an int() is missing.