Module 0-2: Variables
A variable in a programming language is a little different than something like a variable in algebra. In a programming language, a variable is a name that you assign a piece of data. You can change a variable's value to anything else afterwards. You can use a variable in place of data. You can make as many variables as you want.
Let's make a simple variable to demonstrate. In Python, the syntax for making a variable is to state the name of your variable, an equals sign, and then the data.
Run this and the number 4 will be printed to the console. Pretty simple, right?
You can also update
aa = 6aaaa = a - 1aaThe answer is 5.
aaWhy would we use variables? It's a very simple concept, but it is essential for a robust program. Variables allow us to track changes to data over a program's run time, giving us the potential to make programs do different things depending on the current state of data.