Skip to Main Content






Think Programming

Making A Cup of Tea

Before we get too much into computations and programs, let's look at a simple example of a program.

Suppose we want to make a cup of tea. There's arguably many different ways to make a cup of tea, but let's use the following set of instructions:

  1. Boil water in an electric kettle.
  2. Put tea bag in a cup.
  3. Pour boiled water into the cup.

The instructions here might be simple enough for a person to follow, even if they've never made a cup of tea before. But for a computer, we need to really spell out each step. Each step can be decomposed into many smaller steps. For example, "boil water in an electric kettle" becomes:

  1. Grab handle of kettle​
  2. Push button to open lid​
  3. Hold open kettle underneath faucet​
  4. Turn faucet on​
  5. Observe water level in kettle. When it reaches the MAX line, turn faucet off.​
  6. Close lid​
  7. Place kettle on base​
  8. Press switch at base of kettle​

Now, you try to break down the second step, "Put teabag in cup", into smaller instructions. Remember, computers are dumb, so we have to really really spell out each step. Eventually when you get into actual coding, the language will differ a little bit, but the idea of breaking down the steps is fundamental. Here is an example of how the steps could be broken down. Check it with your own steps. Did you miss anything? Do you have anything extra? How does your list differ?

Put teabag in cup:

  1. Grab cup from cupboard​
  2. Set cup on counter​
  3. Grab teabag from box​
  4. Open teabag wrapper​
  5. Take teabag out of wrapper​
  6. Place teabag in cup, keeping string and tag outside of the cup​
  7. Throw out wrapper​

One thing you should notice about this exercise is that some steps are similar, for example the steps that have "grab" as the action, with different objects following the instruction. Additionally, we are making some assumptions in this code, like knowing that the tea bag is in the box, and the cup is in the cupboard.