Skip to content
Skip to main content

About this free course


Download this course

Share this free course

Simple coding
Simple coding

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

2 Sequence

The simplest Python program is a sequence of instructions, written one per line, and executed one by one from top to bottom. Our first program only has two instructions. Here is the program again, already run for you. (You may just see the result of running the code. To see the code itself, click on the pencil icon.)

Remember to open the link to Python in a new tab.

Interactive feature not available in single page view (see it in standard view).

The first instruction is an assignment: the computer evaluates the expression to the right of the assignment (=) and stores the result in the variable on the left of the assignment. Each piece of data we need has to be stored in a variable. Translating Python to English, the assignment states ‘let result be the sum of 3 and 7’.

The second instruction, print, prints some text on the screen, followed by the computed result. Note the following:

  • the comma separates the two things to be printed, in the same way we use commas in English to enumerate two, three, or more things;
  • text is written between double-quotes, which are not printed themselves. In Python, a sequence of characters surrounded by double-quotes is called a string.