Development preview · Sample courses · No real payments or qualifications issued
← Computing & programming foundations
Computing · Lesson 1 of 3

Variables and values

The essentials

A variable is a name referring to a value. In Python, assignment uses =. Equality comparison uses ==. Programs execute statements in order unless control flow changes that order. Reading code step by step is called tracing.
Worked example
x = 3 x = x + 2 print(x) The output is 5. The second line reads the old value and assigns the new value.
Check your understanding

After x = 4 followed by x = x * 3, what is x?

Choose one answer
Sign in with ChatGPT to practise

Practice is untimed. Retry as needed. A correct answer marks this sample lesson complete.

Next lesson →