List Introduction

An introduction to the List data type in Python

List Introduction

A list is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Just as strings are defined as characters between quotes, lists are defined by having values between square brackets [ ].

A list of integers looks like this:

[-3, -2, -1, 0, 1, 2, 3]

A list of floats looks like this:

[3.14, 9.23, 111.11, 312.12, 1.05]

A list of strings:

['shark', 'cuttlefish', 'squid', 'mantis shrimp']

If we define our string list as sea_creatures:

sea_creatures = ['shark', 'cuttlefish', 'squid', 'mantis shrimp']

We can print them out by calling the variable:

print(sea_creatures)

And we see that the output looks exactly like the list that we created:

['shark', 'cuttlefish', 'squid', 'mantis shrimp']

Lists are a very flexible data type because they are mutable in that they can have values added, removed, and changed. There is a data type that is similar to lists but that can’t be changed, and that is called a tuple.

Introduction

Write a program that displays on screen a list of five items.

Write a program that displays on screen two list of differing data types.

Write a program to see if two lists are identical using Boolean Logic.

4.1 Lists Introduction Task
Submit your completed task...
If you need to get in touch with Mr McG then this is the way….

What's your name?
image/svg+xml
Thank you [name], that's great.

Can I ask where you are from?
image/svg+xml
Hey [name], can I ask where you are from?
image/svg+xml
Hey [name], which class are you in?
image/svg+xml
OK [name], thanks for that.

I will need your email address so I can get back to you!!
image/svg+xml
Thanks [name], nearly there.

What can I help you with?
image/svg+xml

Thanks [name] from [whichclass][location], Mr McG will get your message…"
[message]"…and will get back to you ASAP via [email]. Catch you soon.

image/svg+xml
Thank you [name], Mr McG got your message.
Thanks [name], Mr McG will get back to you as soon as he can!!

Have a great day!!

K McGuinness - 2018

No personal data will be shared with any third party. The only data processed via this website is anonymous browsing data to best manage your user experience.