Week 11 Lab - Python Collections

Python Collections

Introduction to Collections

  • Overview of different collection types in Python

  • Key collections: List, Tuple, Set, Dictionary

List

  • Definition: An ordered and changeable collection that allows duplicate members.

  • Characteristics:

    • Ordered

    • Changeable

    • Allows duplicates

Tuple

  • Definition: An ordered and unchangeable collection that allows duplicate members.

  • Characteristics:

    • Written with round brackets

    • Ordered

    • Unchangeable

    • Indexed (first item: index [0])

Creating Tuples

  • Example of creating a tuple:

    • `tuple1 = (

robot