Module 3 - Section 2 - Lists

After the completion of this module the students will be able to:
  • identify the various data types
  • recognize lists
  • create lists
  • use the list methods
  • use the random function

3.2.1 - Data types

So far we have seen three types of data :

and we learned that we can display the type of data with type function.

You can try the following to remember types :

>>> type(3)

>>> type(3.14)

>>> type("Hello")

We have also spoken about statements and we know that some are True and others are False. Try the following code :

>>> type(True)  # without quotes

>>> type(False) # without quotes

This is another type of data called Boolean and could be one of this words.

List is another type of data. We have created lists using the command range. Then we created lists of numbers.

>>>  list(range(1,11))

But a list can contain multiple data. Lets try an example with numbers:

>>> my_list = [1,33,18]

>>> print (my_list) # this is a list of numbers