Assignment
Assignment is associating a name with a value … it’s like naming quantities in algebra, but slightly different
In programming we write …
- The letters “interest_rate” are called a variable in programming because they can take on many values
- Variables have to be single words, always beginning with a letter, so the underscore symbol (_) connects the parts for readability … capitals work for this purpose too:
- Example variables: interestRate, x15, b44zrptq261
- The equal sign is read: “is assigned,” “becomes” or “gets”
- A good metaphor for a variable is a labeled container … since we speak of the “contents” of a variable, i.e. its current value