Further Reading: Control Flow, Functions, and Thinking Like a Programmer

You've just learned the structures that turn individual Python statements into real programs. If you want to deepen your understanding of any of these ideas — or just see them explained in a different voice — here are the resources I'd recommend.


Tier 1: Verified Sources

These are published books with full bibliographic details. Each one covers the material from this chapter (and much more) from a slightly different angle.

Allen B. Downey, Think Python: How to Think Like a Computer Scientist (O'Reilly, 3rd edition, 2024). If you want a second explanation of conditionals, loops, and functions, Downey's book is one of the best introductory Python textbooks ever written. It's clear, concise, and emphasizes thinking over syntax — exactly the philosophy of our chapter. Chapters 5 ("Conditionals and Recursion"), 6 ("Return Values"), and 7 ("Iteration") align closely with what you've just learned. The third edition uses Python 3 throughout. An earlier edition is also available for free on the author's website under an open license.

Al Sweigart, Automate the Boring Stuff with Python: Practical Programming for Total Beginners (No Starch Press, 2nd edition, 2019). Sweigart's book takes a "learn by doing" approach — each chapter solves a practical problem (renaming files, scraping websites, manipulating spreadsheets). Chapters 2 ("Flow Control") and 3 ("Functions") cover the same ground as our Chapter 4, but with different examples. If you learn best by seeing lots of practical applications, this is the book for you. The full text is also available for free on the author's website.

Eric Matthes, Python Crash Course: A Hands-On, Project-Based Introduction to Programming (No Starch Press, 3rd edition, 2023). Another excellent beginner Python book, project-oriented and well-paced. Chapters 5 ("If Statements"), 7 ("User Input and while Loops"), and 8 ("Functions") cover the same topics as our chapter. Matthes has a gift for clear, patient explanation, and his end-of-chapter exercises are well designed. A good companion text if you want more practice problems.

John V. Guttag, Introduction to Computation and Programming Using Python (MIT Press, 3rd edition, 2021). This is the textbook used in MIT's famous introductory computer science course (6.0001). It's more rigorous than the other recommendations — it includes computational complexity and more formal treatment of abstraction — but it's still accessible to beginners. If you're interested in the computer science behind what you're learning (why functions matter conceptually, what abstraction really means), Guttag's book goes deeper than most introductory texts.


Tier 2: Attributed Resources

These are online resources, documentation, and community materials that are well-known and useful for the topics covered in this chapter.

Python Official Tutorial — "More Control Flow Tools" (docs.python.org). The official Python tutorial has a section on control flow that covers if statements, for loops, range(), break, continue, else clauses on loops, pass, match statements, and function definitions — all in one place. It's concise and authoritative. Search for "Python tutorial control flow" or navigate to docs.python.org and find Section 4 of the tutorial. This is the definitive reference for Python syntax questions.

Python Official Documentation — "Defining Functions" (docs.python.org). The official docs on function definitions cover parameters, default values, keyword arguments, and docstrings. When you need to know exactly how Python handles a particular function feature, this is where you look. Search for "Python defining functions docs."

Ned Batchelder, "Loop Like a Native" (PyCon US 2013 talk). Batchelder's conference talk explains how experienced Python programmers write loops — specifically, how to avoid clunky range(len(...)) patterns and use more Pythonic approaches. You've used range(len(...)) in this chapter, which is perfectly fine for learning. Batchelder's talk will show you cleaner alternatives like enumerate() and zip() that you'll want to adopt as you get more comfortable. Search for "Ned Batchelder loop like a native."

Raymond Hettinger, "Transforming Code into Beautiful, Idiomatic Python" (PyCon US 2013 talk). Hettinger — a Python core developer — demonstrates how to refactor common Python patterns into cleaner, more readable versions. Many of his examples involve loops and functions. This is an "after you're comfortable with the basics" resource — watch it after you've finished Part I of this book. Search for "Raymond Hettinger transforming code beautiful idiomatic Python."


  • If you want more practice with conditionals and loops: Work through the exercises in Sweigart's Automate the Boring Stuff or Matthes's Python Crash Course. Both have extensive practice problems with solutions available.

  • If you want to understand functions more deeply: Read Downey's Think Python, which introduces recursion (functions that call themselves) and builds toward more sophisticated function usage. We don't cover recursion in this textbook, but it's a fascinating concept if you're curious.

  • If you want the official reference: Bookmark the Python tutorial at docs.python.org. It's the single most reliable source for "how does this Python feature actually work?" questions.

  • If you're eager to see these skills applied to data: Just keep reading! Chapter 5 introduces the data structures (lists, dictionaries) that make loops and functions truly powerful for data work. By Chapter 6, you'll be analyzing a real dataset using everything you've learned so far.


A Note on Practice

Programming is a skill, not a body of knowledge. Reading about functions is like reading about swimming — it helps, but it's not the same as doing it. The single most effective thing you can do right now is write more functions. Pick a small task — converting temperatures, validating email formats, computing tip amounts — and write a function for it. Then write another. Then make them work together.

The programmers who grow fastest aren't the ones who read the most books. They're the ones who write the most code.