Learn to Code by Solving Problems is a practical introduction to programming using Python. It uses coding-competition challenges to teach you the mechanics of coding and how to think like a savvy programmer.
Computers are capable of solving almost any problem when given the right instructions. That’s where programming comes in. This beginner’s book will have you writing Python programs right away. You’ll solve interesting problems drawn from real coding competitions and build your programming skills as you go.
Every chapter presents problems from coding challenge websites, where online judges test your solutions and provide targeted feedback. As you practice using core Python features, functions, and techniques, you’ll develop a clear understanding of data structures, algorithms, and other programming basics. Bonus exercises invite you to explore new concepts on your own, and multiple-choice questions encourage you to think about how each piece of code works.
You’ll learn how to:
• Run Python code, work with strings, and use variables
• Write programs that make decisions
• Make code more efficient with while and for loops
• Use Python sets, lists, and dictionaries to organize, sort, and search data
• Design programs using functions and top-down design
• Create complete-search algorithms and use Big O notation to design more efficient code
By the end of the book, you’ll not only be proficient in Python, but you’ll also understand how to think through problems and tackle them with code. Programming languages come and go, but this book gives you the lasting foundation you need to start thinking like a programmer.
Author Bio
Dr. Daniel Zingaro is an award-winning Associate Professor of Computer Science in the teaching stream at University of Toronto Mississauga, and is internationally recognized for his expertise in Active Learning. He is also the author of Algorithmic Thinking (No Starch Press, 2021).
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on Python primer that teaches programming through real coding-competition problems, ideal for absolute beginners who want to learn by doing rather than by reading abstract theory.
【Book Arc】
- **Opening (~0%–14%)**: Sets up the book’s philosophy—learning Python by solving actual contest problems—and walks through installing Python, using the shell, and submitting solutions to online judges like DMOJ, Timus, and USACO. This stage solves the “where do I start?” problem by giving immediate, concrete tasks.
- **Early (~14%–29%)**: Covers the absolute basics: strings, variables, integers, floats, input/output, and the first complete programs (e.g., Word Count, Cone Volume). The focus is on getting syntax right and understanding how a program flows from reading input to producing output.
- **Early (~29%–36%)**: Introduces decision-making with booleans, relational operators, and `if`/`elif`/`else` statements, plus boolean operators (`and`, `or`, `not`). Problems like Telemarketers force you to translate everyday logic into precise code, and the section ends with comments and input/output redirection for testing.
- **Middle (~36%–46%)**: Dives into loops, starting with definite `for` loops (including nesting and range-based indexing) and then indefinite `while` loops. Key problems (Three Cups, Occupied Spaces, Data Plan, Slot Machines, Secret Sentence) show when each loop type fits, and `break`/`continue` are introduced as control-flow tools.
- **Late (~46%–100%)**: Moves from syntax to structure: lists for organizing values, functions for top-down design, file reading/writing, sets and dictionaries for efficient data handling, complete-search algorithms, and finally Big O notation to reason about efficiency. The book closes with an afterword and problem credits, tying the skills back to real contest contexts.
【Key Takeaways】
- **Learning by solving is the core method** (Opening): every chapter is built around a contest problem, so you’re not just memorizing syntax—you’re applying it immediately to a concrete goal. This keeps motivation high and makes each concept stick.
- **Online judges are your feedback loop** (Opening): the book teaches you to submit code to DMOJ, Timus, and USACO, where automated judges test your solution against hidden cases. This simulates real-world correctness checking and teaches you to write robust code, not just code that works on one example.
- **Strings and variables are the first building blocks** (Early): before loops or functions, you master how to represent text, store values, and manipulate them with operators and methods. The Word Count problem is a deceptively simple first win that builds confidence.
- **Decisions are about precision, not just `if`** (Early): boolean types, relational operators, and `and`/`or`/`not` force you to specify exactly when a condition holds. The Telemarketers problem is a great test of translating messy real-world rules into clean logic.
- **Choosing the right loop is a design decision** (Middle): `for` loops are for when you know the number of iterations; `while` loops handle unknown counts, like reading until a condition changes. The book explicitly contrasts these with problems like Slot Machines, where `for` fails and `while` shines.
- **Data structures change how you think** (Late): lists, sets, and dictionaries aren’t just storage—they enable different algorithms. Sets and dictionaries, in particular, let you organize and search data in ways that are both faster and more readable, a step up from raw lists.
- **Efficiency is a skill, not an afterthought** (Late): the final chapters on complete search and Big O teach you to reason about whether your solution will run in time. This is the bridge from “it works” to “it works well,” a mindset that separates hobbyists from serious programmers.
【Reading Tips】
- **Skim the setup, but don’t skip the problems**: the early chapters’ installation and shell instructions are standard—skim them if you’ve used Python before. The real value is in attempting each problem before reading the solution; struggle first, then learn.
- **Deep-read the “Solving the Problem” sections**: these walk through the full reasoning from problem statement to final code. They’re where the book teaches you to think, not just to type, so read them slowly and trace the logic.
- **Use the online judges as intended**: don’t just read—submit your solutions. The judge’s feedback (accepted, wrong answer, time limit exceeded) is the most honest assessment of your code, and it’s the book’s unique advantage over typical tutorials.
- **Watch for the loop-type contrasts**: chapters 3 and 4 are where beginners often get stuck. Pay extra attention to why `for` fails in certain problems (like Slot Machines) and how `while` solves it—this distinction is a classic stumbling block.
- **Treat the final chapters as a mindset shift**: Big O and complete search are conceptually harder than syntax. If you’re short on time, read them for the ideas, not the details, and return later when you’ve practiced more.
【Coverage Limits】
This guide synthesizes the book’s structure and key teaching moments from the available excerpts, which cover roughly the first half in detail (through loops) and outline the rest. Specific problem solutions, code listings, and the full text of later chapters (lists, functions, files, sets, dictionaries, algorithms) are not detailed here—read the book for those.
Page 4
oc.gov/2021011082 LC ebook record available at https://lccn.loc.gov/2021011083 No Starch Press and the No Starch Press logo are registered trademarks of No S...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Learn to Code by Solving Problems A Python Programming Primer (Daniel Zingaro)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Learn to Code by Solving Problems A Python Programming Primer (Daniel Zingaro)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment