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.

Free course

Simple coding

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. (If you’re reading this tutorial on a narrow screen 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.

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.
SCOD_1

Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371