Lesson: Lists and For Loops

This lesson is part of our introductory Python Course: Python for Data Science Fundamentals.


Building on what was taught in the Programming in Python lesson, you will continue to build and refine your Python programming skills by learning to work with lists in Python, and learn the basics and syntax of Python for loops to analyze data so you can build your confidence in using Python for data science.

In this lesson, you'll learn concepts such as data structure in Python — known as a list —to organize your data, making it easily retrievable. You’ll also learn how to retrieve data from a list, slicing a list, Python for loops, and how to compute the average using for loops. For loops are important and super awesome because they loop through an iterable object (like a list, tuple, set, etc.) and perform the same action for each entry. For example, a for loop would allow us to iterate through a list, performing the same action on each item in the list.

Upon completion of this lesson, you'll feel more confident in your Python programming ability. If you feel like you need practice, think of something you can create using what you've learned so far — it doesn't have to be big, it can be something small, like a calculator. Or if you feel like you need more practice with Python for loops (it's a tough concept to grasp), check out this tutorial explaining the basics of for loops

Objectives

  • Learn to work with list in Python.
  • Learn to work with lists of lists in Python.
  • Learn to use Python to open a data set stored on a file.
  • Learn to analyze data using Python for loops.

Lesson Outline

1. Lists
2. Indexing
3. Negative Indexing
4. Retrieving Multiple List Elements
5. List Slicing
6. List of Lists
7. Opening a File
8. Repetitive Processes
9. For Loops
10. The Average App Rating
11. Alternative Way to Compute an Average
12. Next Steps
13. Takeaways