
Explore Python best practices focused on built-in data types—lists, tuples, sets, and dictionaries—with author James Powell, covering basics and practical applications.
Explore how to choose and use Python's dict type idiomatically, leveraging built-in data structures and the standard library to write clearer, more efficient code.
Explore how Python dictionaries relate to look-up tables, maps, and other names across languages, revealing similar features to guide idiomatic and effective use.
Explore how dict.copy creates a shallow copy of a dictionary, copying keys but keeping values as references, and how the copy module provides a deep copy function for nested structures.
Explore python's defaultdict from the collections module, which auto-creates a default value for missing keys using a factory, like an empty set, enabling seamless updates.
Demonstrates building a Vigenere cipher encoder with a two-level dictionary codebook, cycling the key, and encoding and decoding letters while stripping non-letter characters.
Explore the Python set type to store unique elements and perform unions, intersections, and differences while building a simple prime finder using trial division up to a maximum.
Describe the Python set type as a unique, unordered collection of hashable items, enabling intersection, difference, and union operations and highlighting its similarities to dictionaries.
Learn how to construct sets in Python using literal syntax and the set constructor, from iterables, handling duplicates, including empty sets, adding elements, and building a 52-card deck.
Build a poker deck as suit and rank tuples using Python sets and frozensets, then identify valid straights to evaluate hands like straight flush, four of a kind, and flush.
Explore simple problem statements using lists and tuples to build a personal rolodex or phone book, with operations to insert, remove, and retrieve entries by name or detail.
Explore the tuple type as a fixed-size, immutable, heterogeneous collection that preserves element positions like records or coordinates, contrasting with mutable lists and showing how to extract elements.
Learn to create tuples in Python using literal syntax or the tuple() function, including one-item tuples with a trailing comma, and representing a person's name and birthday.
Explore list comprehensions and generators, explain that tuple comprehensions don’t exist, and show how to build tuples with tuple() from a list comprehension or a generator expression, including even squares.
Set items in lists by assigning to an index or a slice. Explain that tuples are immutable, so set item syntax cannot modify them.
Explore iteration for lists and tuples in Python, using for loops, slicing, and enumerate, and learn why modifying a collection during iteration can skip items and is best avoided.
Explore how count and index work on lists and tuples, counting element occurrences and locating the first index, with apples, bananas, and a tuple of names including missing-element behavior.
Explore Python's collections.namedtuple to create named-field records and access fields by name. See a practical example counting years after leaving office and visualizing with histograms.
This Python Best Practices training course, covers the built-in data types in Python. This course is designed for beginning to intermediate Python users.
You will start by learning about data structures, including the dict type, problem statements, terms, and how to create a dict. From there, the author will teach you how to interact with the set type, such as type constructing, comprehension, and indexing. Finally, this video tutorial covers list and tuple types, including the list type, how to create a list and tuple, and semantics.
Once you have completed this computer based training course, you will have gained a solid understanding of the built-in data types in Python. Working files are included, allowing you to follow along with the author throughout the lessons.