DS 1501 · Lesson 13 of 24
Instructor: Corey Schafer29m
Sign in to watchBridge from lists into tuples and master intermediate Python sequence operations used constantly in Data Science pipelines. What you will learn: • Tuple syntax, single-element trailing comma gotcha (t = (5,) vs (5)), packing, and unpacking (x, y = y, x). • Immutability guarantees of tuples (safe fixed records, valid dict keys) vs mutable lists holding nested objects. • Advanced list operations: sort() vs sorted(), key= sorting, reverse(), count(), index(), copy(), and 2D list matrices. • Building transformed and filtered lists concisely with list comprehensions ([x*x for x in nums if x > 0]). University Outline Mapping: Class 13 · CO3 · Reading: 5.3–5.6 (deitel) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 13 | CO3 | Reading: Deitel 5.3–5.6 Key Distinctions to Remember: • lst.sort() sorts in-place and returns None (Assignment trap: x = lst.sort() sets x = None!). Use sorted(lst) for a new list. • A single-element tuple MUST have a comma: single = (42,) -> tuple; (42) -> int. • Extended unpacking: first, *middle, last = [10, 20, 30, 40].
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community