Master Python

Change from the till

Change from the till

A market stall keeps its till entirely in pence, because pence are whole numbers and pounds are not. When somebody buys several of the same thing, the till needs to work out the change.

Write change, which is handed the amount the customer gave over, the price of one item, and how many of them they bought, all in pence. Return the change owed.

Worked example

Input:  paidPence = 1000, itemPence = 250, quantity = 3
Output: 250

Three coffees at 250p each cost 750p.
The customer handed over 1000p.
1000 - 750 = 250p of change.

Constraints

  • All three numbers are whole numbers of pence.
  • paidPence is between 0 and 100000.
  • itemPence is between 0 and 10000.
  • quantity is between 0 and 1000.
  • The customer may not have handed over enough. If so the answer is negative, and a negative answer is the right answer: it is what they still owe. Do not adjust it.
Code

Run your code to see how it does on the examples. Submit also runs the hidden cases.