wunder beta

🧩 Programming II

Move beyond the basics into structure and reuse. You'll work with data structures, classes, and modules and write programs that are organized and testable.

15
lessons
~90 min
to learn
🔬 Science
subject
Adults
level
Start the course →

What you’ll learn

  1. From Scripts to SoftwareExplain why structure — not syntax — is what lets programs scale.Margaret Hamilton's Apollo team named "software engineering" to demand rigor for code, and the 1960s software crisis proved the point. Structure buys readability, reuse, testability, and safe change — the themes of every lesson that follows.
  2. Lists in DepthUse lists fluently: indexing, mutation, methods, and half-open slicing.Lists are ordered, zero-indexed, and mutable — append, assign by index, sort in place. Slices include start and exclude end (letters[1:4] is three items), and negative indexes count from the tail. Punch-card decks were this abstraction in cardboard.
  3. Dictionaries: Instant LookupUse dictionaries for key-value data and explain why hashed lookup is fast.Dicts map unique, hashable keys to arbitrary values with near-constant-time lookup, the software descendant of the card catalog. Bracket access raises KeyError on missing keys; .get() offers defaults; .items() iterates pairs.
  4. Stacks and QueuesImplement stack (LIFO) and queue (FIFO) behavior and match each to its uses.Stacks surrender the newest item first — undo, back buttons, the call stack; queues honor arrival order — print jobs and tickets. Python lists stack naturally via append/pop; collections.deque queues efficiently.
  5. Tuples and SetsContrast list, tuple, set, and dict as behavioral contracts.Tuples freeze an ordered group (and can key dicts); sets enforce uniqueness with instant membership tests; lists remain the mutable general sequence. Choosing a container is choosing which guarantees the language enforces for you.
  6. Choosing the Right Data StructureChoose data structures from access patterns and justify the choice.Lookup-by-key wants a dict, ordered editable data a list, membership and de-duplication a set, frozen groups a tuple. The wrong choice still runs — a list scan versus a hash jump across a million records is the cost, as physical as warehouse shelving.
  7. Functions Revisited: Scope and ArgumentsApply the LEGB rule and prefer arguments/returns over global state.Names resolve Local → Enclosing → Global → Built-in, and assignment inside a function creates a local that shadows any global. Scope is the containment that makes a thousand functions coexist — the disciplined descendant of ENIAC's plugboard programming.
  8. Classes and ObjectsDefine classes with __init__ and methods, and explain self and per-object state.A class is a blueprint bundling data with behavior; each object carries its own attributes, stamped on self by __init__. Methods receive self first, which is how account.deposit(50) knows whose balance to change.
  9. Inheritance and CompositionModel "is a" with inheritance and "has a" with composition — and know which to reach for.Subclasses inherit and specialize parents (ElectricCar is a Car); composition assembles objects from parts (Car has an Engine). Real systems contain more has-a than is-a, so seasoned designers compose first and inherit deliberately.
  10. Modules and PackagesOrganize code into modules and packages and reason about the import search path.Every file is a module imported under a namespace; packages group modules. Imports resolve through cached modules, your directory, installed packages, then the standard library — which is why a local random.py shadows the real one, and why the "batteries included" stdlib deserves a look before writing utilities.
  11. Errors and ExceptionsHandle failures with specific try/except blocks and recognize common exception types.Exceptions jump control to a matching except handler instead of crashing; catch the specific error (ValueError, KeyError, IndexError, TypeError) and let the rest stay loud. The craft is as old as the 1947 moth taped into the Mark II logbook.
  12. Files and PersistenceRead and write files safely with context managers and standard formats.Memory dies with the process; files persist. with open(...) guarantees closure even through exceptions, and standard formats — CSV for tables, JSON for nested data — via the csv and json modules beat inventing your own.
  13. Testing Your CodeWrite arrange-act-assert unit tests and target edge cases.A test asserts a contract on known inputs and fails loudly on regression; suites run after every change convert fear into a five-second check. Edge cases — empty lists, zeroes, bad input — are where bugs live, a rigor Apollo's alarm-surviving guidance software proved out.
  14. Refactoring and StyleRefactor behavior-preservingly and apply PEP 8 conventions.Refactoring improves names, extracts functions, and removes duplication in small, test-verified steps. PEP 8 — snake_case, CapWords, named constants — is Python's shared grammar, carrying Grace Hopper's founding argument that code is written for humans.
  15. Designing a Small ProgramDesign a small program end to end: I/O, structures, decomposition, tests, refactor.State inputs and outputs, choose structures by access pattern, decompose into single-job functions, implement piecewise with tests, then refactor on green. Every course topic is one discipline — controlling complexity — and the next teacher is a real project.

Questions this course answers

Why does program structure matter more as code grows?

Structure exists for people: readability, reuse, testability, and safe change. The machine would happily run a 3,000-line blob — you could not maintain one.

letters = ['a','b','c','d','e']. What is letters[1:4]?

Slices include the start index and exclude the end — indexes 1, 2, 3. The half-open convention makes result lengths simply end minus start.

Why are dictionary lookups fast even with millions of entries?

Hashing jumps straight to the key's slot instead of scanning — near-constant time regardless of size, the same trick as a card catalog's filing system.

Asking d["missing"] for a key that does not exist:

Bracket lookup on a missing key raises KeyError. Use d.get("missing", default) when a fallback is the desired behavior.

An undo feature should store actions in:

Undo must reverse the newest action first — last in, first out. Print jobs and ticket systems, which honor arrival order, are queue territory.

Which container automatically eliminates duplicates?

Sets hold unique items only: set([3,1,3,2,1]) is {1,2,3}. They also make "is x in here?" checks nearly instant.

Grounded in trusted sources

  • Python Software Foundation — The Python Tutorial and Language Reference (docs.python.org)
  • PEP 8 — Style Guide for Python Code (python.org)
  • Eric Matthes, Python Crash Course (No Starch Press)
  • Al Sweigart, Automate the Boring Stuff with Python (No Starch Press)
  • NASA/MIT — Apollo Guidance Computer software history (Margaret Hamilton, MIT Instrumentation Laboratory)

Every Wunder lesson is built from real, reputable sources — never invented.

Related Science courses

Wunder is a personalized learn-anything platform — tell it any topic and it builds a beautiful, fact-checked course in minutes, with narration, a knowledge check, and a college-style University track.

Browse more Science courses · All topics · Home

© 2026 Wunder Learning LLC · Terms & Privacy