Novice · Arithmetic · 30 of 264
Change
A shop sells something for a price; the customer pays with a larger note. Print the change.
Input: the price and the amount paid, whole numbers, one per line. Output: Change: <paid - price>
Examples
Input
35 50
Output
Change: 15
Input
99 100
Output
Change: 1
Input
0 20
Output
Change: 20
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.