Loops and Core Data Structures

This session covers fundamental Python data structures, iteration techniques, and practical loop patterns, using a campus coffee cart sales dataset as a practical working example.

It begins by introducing Python’s four built-in containers, contrasting how ordered lists allow duplicates and in-place modifications, tuples store fixed records that cannot be changed, sets keep only distinct values for membership testing with in and not in, and dictionaries map unique keys to values. The material covers essential methods including indexing, slicing, list comprehensions, tuple unpacking, and using .get() to prevent lookup errors.

The session also explores looping mechanisms, examining for loops over sequences, ranges, and enumerated items, alongside condition- and sentinel-controlled while loops. Finally, it establishes four fundamental loop patterns—counting matches, accumulating running totals, filtering items into new lists, and finding maximum or minimum values—as well as techniques for counting item popularity using dictionaries and collections.Counter.

Figure: Abstract image representing loops and containers

Listen

Python Programming Blueprints

Read

Hands-on

Notebooks in 03-Loops-Data-Structures

Special CLI Commands

Use the following CLI commands on the Analytics Research Cluster

CommandWhat it does
ifi8410-statusChecks everything and tells you where you stand. Start here.
ifi8410-updateBrings in new files from your instructor.
ifi8410-testSaves your work and runs the automatic tests on it.
ifi8410-submitSays “this is the version I want graded”.

Read the document IFI-8410 Course Tools

References