Variables & Constants

Coding: Introduction to Python v3, topic 1.4.1

Variables and Constants

Variables and constants allow us to store results in the main store.

Variables

Variables

  • Variables are named spaces in the memory where data can be stored.
  • The value of a variable is the data stored inside it.
  • The value can change whilst the program is running.
Constants

Constants

  • Constants are similar to variables, but the value cannot change whilst the program is running.
  • Constants make the code easier to read.
Assignment

Assignment

  • To use a variable, we give it a name and a value. For example:
  • x = 50
  • We can then use this variable in other expressions by using its identifier (name).

Test yourself on Variables & Constants

  • Which of these statements is true about constants?

  • Which symbol is used to assign values?

  • What should constants be used for?

Practise this topic for free