Introduction to Python
Google uses Python extensively in its web search systems and even employed Guido van Rossum, the inventor of Python.
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.
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)
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.
Google uses Python extensively in its web search systems and even employed Guido van Rossum, the inventor of Python.
Why do we need to know if a data type is text or a number? Because Python needs to understand if an item is a number to perform calculations with it.
Once we have a variable of a data type in python that is either an integer or a float, we can perform mathematical operations on it.
Why should we learn to use Python built-in functions? Because they can save us a lot of time when we’re programming.
We already discussed how to use several data types. Now, we’ll talk about another data type called list.