Using variables and functions
In Python, we use variables to store a value. We can then use the value to perform operations, evaluate expressions, or use them in functions. Functions give sets of instructions for the algorithm to follow when they are called in an algorithm. Many functions include variables within them. So, let's first look at how we define and use variables, then take a look at Python functions.
Variables in Python
Python does not have a command for declaring variables. We can create variables by naming them and setting them equal to whatever value we'd like. Let's take a look at an algorithm that contains multiple variables:
ch8_variables.py
name = 'Marcus' b = 10 country_1 = 'Greece' print(name) print(b) print(country_1)
As you can see, we can use a letter, a longer name, and even include underscores in naming our variables. We cannot, however, start a variable name with a number. When we run this program, we get...