TensorLearn
Back to Course
Python Essentials: The Engineering Approach
Module 6 of 20

6. Lists & Tuples

Understanding Vectors

A List in Python is a Dynamic Array. It stores pointers to objects. This means it has O(1) access time but can be slow to insert items in the middle.

Slicing

The power of colon :.

python
# [start:stop:step] nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(nums[::2]) # [0, 2, 4, 6, 8] (Evens) print(nums[::-1]) # [9, 8, ... 0] (Reverse)

Tuples

Tuples are Immutable Lists. Why use them?

  1. Safety: Data cannot be changed by accident.
  2. Speed: Python optimizes memory for tuples.
  3. Hashable: Can be used as dictionary keys (Lists cannot).
python
point = (10, 20) x, y = point # Unpacking

Mark as Completed

TensorLearn - AI Engineering for Professionals