As described in the previous video, behind the scenes Python stores data in different ways depending on it’s type. You often don’t need to worry about this to begin with, and as you improve in programming skills you will get used to the different data types. Below is a summary table of the main ones.
Data type
Kind of Data Stored
Examples
int
Integers – whole numbers
1, 500, 9040
float
Fractional numbers
1.1, 500.75, 0.00041
string
Text
“Hello”
boolean
True or False
True, False
A slightly more complex data type we often use is called a list. Very simply, this just stores a list of items, from the datatypes above. Let’s see an example:
numbers = [3, 56, 42, 9]
‘numbers’ is variable which holds several individual data items – it holds a list of numbers.
To access the particular member of a list we use square brackets, e.g. to get at the second item we can do
print numbers[2]
This will print “42” – note the counting starts from 0 (item 0 is the first item in a list)