Variables, Arrays, and Substitutions
Variables are one of the core concepts in any scripting language. They allow developers to store information in memory using a descriptive name and then later reference that information in their script. Variables can store integers, decimal numbers, Boolean (true/false) values, dates and times, character strings, and virtually any other type of information that you might need.
Let’s take a look at how we might use a variable in some pseudocode. Imagine that we have a small store that normally sells cupcakes for $2 but offers a 50 percent discount on Tuesdays. We might need a script that calculates Tuesday’s price, like this one:
cupcake_price = 2
cupcake_price = cupcake_price / 2
print "The price of a cupcake is ", cupcake_price
In this script, cupcake_price is a variable. The first line of the script sets the value of that variable equal to 2.00. The next line changes the price to one-half of its current value...