Last time, we saw how to print multiple things on one line using commas, like:
Engagement Message
What was the exact output of that command?
Sometimes, we want to save a piece of information to use later in our program. Think of it like putting something in a labeled box so you can find it easily when you need it.
Engagement Message
Does that idea make sense?
In programming, these labeled boxes are called variables. We create a variable and give it a value using the equals sign (=
).
For example:
message = "Hello again!"
Here, message
is the variable name (the label on the box).
Engagement Message
What value did we store inside the message
variable?
Once you've stored something in a variable, you can use the variable's name wherever you would have used the value itself.
For instance:
Engagement Message
What do you think running these two lines would output?
Variables aren't just for text! They can hold numbers too.
The computer remembers that holds the number and uses it in the command.
