Skip to content

Instantly share code, notes, and snippets.

@neanias
Created January 28, 2019 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neanias/357092ab14e2c185bd172584e02d4cbf to your computer and use it in GitHub Desktop.
Save neanias/357092ab14e2c185bd172584e02d4cbf to your computer and use it in GitHub Desktop.

A basic exercise to help learn the basics of Python

A change dispenser

Write a programme for an automatic change dispenser. It will choose the correct coins to dispense based on the amount required. It should work like this:

  1. Prompt the user for a number between 0 & 99 (this represents the change due.)
  2. Output the correct number of 50p, 20p, 10p, 5p, 2p or 1p coins to dispense.

NB: You may find the mathematical operators // (integer division) and % (modulo function) helpful.

An example running of this programme might be:

$ python3 change_dispenser.py

How much change is to be dispensed? 75p
50p 20p 5p

Useful resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment