3.1: 🔢 Numerical Variables

Topic

3.1: 🔢 Numerical Variables

Topic Progress:

Python’s basic variables can contain several different types of information, the first of which is numbers. In this first lesson, we will be taking a look at numerical (number) variables in python. Remember, variables are containers holding pieces of information – so numerical variables are containers holding numbers.

Before we can start coding, we need to learn how to make and change variables. To make a variable, we must first give it a name: eg, ‘aVariable’. Then, we have to give it a value, using ‘=’. In code, this can look like:

aVariable = 5

This creates a new variable called “aVariable”, and gives it a value, 5.

If we want to change the value of a variable, all we need to do is reference it again the same way, like this:

anotherVariable = 1
anotherVariable = 10

After the second line of code runs, the value of anotherVariable will be changed from 1 to 10. Remember, when we use numerical variables, we can put them anywhere we would usually put a number!

For this section, your task is to make one change to the first line of the following code, so that the print() statement outputs the number 3.

@

Not recently active