List Data Type in Python

We already discussed how to use several data types. Now, we’ll talk about another data type called list.

Intro to List Data Type

Welcome to Level 5

We’re making amazing progress. In terms of the what, why, and how of Level 5, let’s kick it off with the what.

What will we learn together?

We already discussed how to use several data types. Now, we’ll talk about another data type called lists.

Why are lists important to learn?

Because we can store lots of data in a list, separated by commas, and not just a single piece of data. This will help you take your Python skills to the next level.

How are we going to learn about lists together?

After explaining how lists work and why they are so useful, we will do exercises together during Level 5. 

How Does the List Data Type Work?

A great way to learn programming is to experiment, try new things, and make mistakes. I do this all the time, and it’s a lot of fun. Programming is like a puzzle or building with Legos, so embrace errors as part of the learning process.

In this chapter, we will introduce the sum function and something called lists, which is really exciting.

In the example below, on the 3rd line, we created a list that stores two items. We use square brackets and separate the items with commas.

Then, on the 4th line, we use the sum function to add the items in the list together.

				
					employee_one_experience = 20
employee_two_experience = 30 
experience = [employee_one_experience,employee_two_experience]
total_experience = sum(experience)
print(total_experience)
				
			

EXERCISE

Please complete the following steps:

    Step 1: Create a list called height, which has 3 numbers in it as follows: Ahsoka is 1.7 meter, Yoda is 0.66 meters and R2D2 is 1.09 meters.
   Step 2: Print the type of variable that height is.
   Step 3: Print the sum of the list called height.

Play Video about finding Video

Other Lecture