Introduction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Creating and organizing data is a key part of creating programs, but data alone does not make for a compelling program. Programs need to act on data. This can be accomplished with branching logic such as making choices based on user input. For instance, did the user set their preference for an alarm sound? If so, play that preference or default to the system standard.

You can also employ loops to rapidly iterate through large datasets. For instance, you can loop through all a user’s geo coordinates to draw their route on a map. For a person, such a task might take hours whereas an iPhone can do it in less than second.

All of this is known as control flow. Control flow means you are controlling the flow of your program’s execution. Think of the user like a marble. The user rolls down the track of your program. Control flow is the various ramps and side routes in your program.

Control flow works great with collections. Collections are ways to organize your data. Whereas a variable is like a single folder that contains a single value, a collection is like a filing cabinet containing thousands of values.

By the end of this lesson, you will:

  • Identify the difference between a loop and an if statement.
  • Detail the differences between an array and a dictionary.
  • Describe how to use a loop to iterate through an array.
See forum comments
Download course materials from Github
Next: if Statements