If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.
Quick Bits on Python Data Structures
Strings
# Syntax 'string' "string" '''string''' """string"""
Lists
- multiple data types
- mutable/changeable
- ordered
- indexed
# Syntax list_name = ['list item 1', 'list item 2', 'list item 3']
Tuples
- multiple data types
- immutable/unchangeable
- ordered
- indexed
# Syntax dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')
Sets
- unordered
- no index
- mutable/changeable
# Syntax dog_parts = {'paws', 'legs', 'tail', 'fur'}
Dictionaries
- key/value pairs
- mutable/changeable
# syntax dogs = { 'name': 'Cheeto', 'colors': ['tan', 'black'], 'age': 4.5, 'chipped': True, 'breed': 'chihuahua', 'weight': 12.8, 'vaccines_due':{ 'rabies': 2022, 'dhpp': 2020, 'kennel_cough': 2020, } }
Top comments (0)