Learn to Code by Solving Problems: A Python Programming Primer
- Length: 336 pages
- Edition: 1
- Language: English
- Publisher: No Starch Press
- Publication Date: 2021-06-29
- ISBN-10: 1718501323
- ISBN-13: 9781718501324
- Sales Rank: #274205 (See Top 100 Books)
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.
Table of contents
1 GETTING STARTED
2 MAKING DECISIONS
3 REPEATING CODE: DEFINITE LOOPS
4 REPEATING CODE: INDEFINITE LOOPS
5 ORGANIZING VALUES USING LISTS
6 DESIGNING PROGRAMS WITH FUNCTIONS
7 READING AND WRITING FILES
8 ORGANIZING VALUES USING SETS AND DICTIONARIES
9 DESIGNING ALGORITHMS WITH COMPLETE SEARCH
10 BIG O AND PROGRAM EFFICIENCY
Cover Page Title Page Copyright Page Dedication About the Author About the Technical Reviewer BRIEF CONTENTS CONTENTS IN DETAIL ACKNOWLEDGMENTS INTRODUCTION Online Resources Who This Book Is For Why Learn Python? Installing Python How to Read This Book Using Programming Judges Making Your Programming Judge Accounts About This Book 1 GETTING STARTED What We’ll Be Doing The Python Shell Problem #1: Word Count Strings Integer and Floating-Point Numbers Counting the Words Using a Variable Reading Input Writing Output Solving the Problem: A Complete Python Program Problem #2: Cone Volume More Math in Python Converting Between Strings and Integers Solving the Problem Summary Chapter Exercises Notes 2 MAKING DECISIONS Problem #3: Winning Team Conditional Execution The Boolean Type Relational Operators The if Statement Solving the Problem Problem #4: Telemarketers Boolean Operators Solving the Problem Comments Input and Output Redirection Summary Chapter Exercises Notes 3 REPEATING CODE: DEFINITE LOOPS Problem #5: Three Cups Why Loops? for Loops Nesting Solving the Problem Problem #6: Occupied Spaces A New Kind of Loop Indexing Range for loops Range for Loops Through Indices Solving the Problem Problem #7: Data Plan Looping to Read Input Solving the Problem Summary Chapter Exercises Notes 4 REPEATING CODE: INDEFINITE LOOPS Problem #8: Slot Machines Exploring a Test Case A Limitation of for loops while loops Solving the Problem The Mod Operator F-Strings Problem #9: Song Playlist String Slicing Solving the Problem Problem #10: Secret Sentence Another Limitation of for loops while Loops Through Indices Solving the Problem break and continue Summary Chapter Exercises Notes 5 ORGANIZING VALUES USING LISTS Problem #11: Village Neighborhood Why Lists? Lists List Mutability Learning About Methods List Methods Solving the Problem Avoiding Code Duplication: Two More Solutions Problem #12: School Trip Splitting Strings and Joining Lists Changing List Values Solving Most of the Problem How to Handle the Catch Problem #13: Baker Bonus Representing a Table Solving the Problem Summary Chapter Exercises Notes 6 DESIGNING PROGRAMS WITH FUNCTIONS Problem #14: Card Game Exploring a Test Case Defining and Calling Functions Function Documentation Solving the Problem Problem #15: Action Figures Representing the Boxes Top-Down Design Summary Chapter Exercises Notes 7 READING AND WRITING FILES Problem #16: Essay Formatting Working with Files Solving the Problem Problem #17: Farm Seeding Exploring a Test Case Top-Down Design Summary Chapter Exercises Notes 8 ORGANIZING VALUES USING SETS AND DICTIONARIES Problem #18: Email Addresses Using a List Efficiency of Searching a List Sets Set Methods Efficiency of Searching a Set Solving the Problem Problem #19: Common Words Exploring a Test Case Dictionaries Indexing Dictionaries Looping Through Dictionaries Inverting a Dictionary Solving the Problem Problem #20: Cities and States Exploring a Test Case Solving the Problem Summary Chapter Exercises Notes 9 DESIGNING ALGORITHMS WITH COMPLETE SEARCH Problem #21: Lifeguards Exploring a Test Case Solving the Problem Problem #22: Ski Hills Exploring a Test Case Solving the Problem Problem #23: Cow Baseball Using Three Nested Loops Sorting First Python Modules The bisect Module Solving the Problem Summary Chapter Exercises Notes 10 BIG O AND PROGRAM EFFICIENCY The Problem with Timing Big O Problem #24: Longest Scarf Exploring a Test Case Algorithm 1 Algorithm 2 Problem #25: Ribbon Painting Exploring a Test Case Solving the Problem Summary Chapter Exercises Notes AFTERWORD APPENDIX: PROBLEM CREDITS INDEX
Donate to keep this site alive
How to download source code?
1. Go to: https://nostarch.com/
2. Search the book title: Learn to Code by Solving Problems: A Python Programming Primer
, sometime you may not get the results, please search the main title
3. Click the book title in the search results
3. Download the Source Code.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.