Skip to the content.

Lists and Filtering Algorithms

Notes

Lists and Filtering Algorithms

What Are Lists in Python?

  • A list is just an ordered collection of stuff like numbers, words, or even True/False values.
  • Lists are mutable, meaning you can change them after creating them.
  • Lists are written in square brackets [].

Creating Lists

  • You can throw a bunch of different types of things into one list, like a mix of numbers, text, or booleans.

Accessing List Items

  • You can grab items from a list by using positive indexing (starting from 0) or negative indexing (starting from -1, counting from the end).

Changing Lists

  • You can update things in a list, add new stuff, or remove things you don’t need anymore.

What Are Filtering Algorithms?

  • Filtering algorithms help you make a new list by picking out things that meet certain conditions.
  • Example: you could filter a list to just show even numbers or people older than a certain age.

Efficiency of Filtering

  • Filtering means going through each item in the list one by one.
  • The bigger the list, the longer it takes to filter through.
  • This is called O(n) time complexity, which basically means the time it takes grows with the list size.

Link to Popcorn Hacks and Homework