Variables and constants

Cards (5)

  • A variable is a named piece of memory that holds a value. The value it holds can, and often does, change during the running of a program.  
  • A constant is a named piece of memory where the value cannot be changed while a program runs. 
  • Constants are useful because they are declared and assigned once, but can be referred to over and over again throughout the program. This means that if the programmer needs to change the value throughout the program code, they only need to make one change. This can help make a program easier to maintain. 
  • Constants follow the same naming conventions as variables, except that they are often written in uppercase.
  • Some programming languages, such as Python, do not support constants.