Lesson goal: Program Flow

Previous: Displaying nice looking math | Home | Next: Programming as a calculator

Computers always execute code from top to bottom and left to right. You can experiment a bit with this idea here. There are three separate statements in the code box below. The print statement tells the computer to display the text within the double quotes, on the screen. Click the "Run my code..." button to see how the computer processes these lines.

Next, arrange (cut and paste) the lines in any order you wish, and run the code again. Prove to yourself that computers run code from top to bottom.

Now you try. Change the top to bottom order of the three print lines. Convince yourself that computers execute code from top to bottom.

Type your code here:

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.