Controlling the execution path
In Chapter 5, Sequence – The Basic Building Block of a Computer Program, we learned that the code within a program is executed in sequence.
There are situations when we only want to execute some code if a condition is met. For example, if you recall our application from Chapter 5, Sequence - The Basic Building Block of a Computer Program which turned on the outdoor light, we had a condition that said if our phone detected that we were within a given range from our house, it should send a signal to the home computer. To refresh your memory, let's take a look at some images you have seen before. Figure 7.1 was used to illustrate the action of us entering the range: