How do computers make decisions? Here are a few examples:

  • Web surfing: Open the browser, load the text, load the images.
  • Social media: If the user’s profile is private, hide their posts. Otherwise, make them visible.
  • Electronic music: Repeat a note four times a measure.
  • Shopping: Collect shipping and contact information. Reject a purchase if either is incorrect.

Each of these programs is a set of instructions, executed in a certain order. This order, called control flow, is just as important as the instructions themselves.

Programmers use control structures to alter control flow. Control structures include conditionals — “do these instructions if Z is true”, loops — “do these instructions X many times”, and exceptions — “do instruction set A, but if an error occurs switch to instruction set B”. Programmers use these structures in their code to tell a computer which instructions (or in which order) to execute.

In this lesson you will learn the fundamental concepts of control flow and three essential control structures. By the end of the lesson you should be able to:

  • Define control flow
  • Explain the difference between conditional, loop, and exception control structures
  • Give examples for each


There are five steps in this program, which loads a basic website. Execute the steps in the correct order by clicking each one.

In what order are the instructions executed?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?