Learn to code by solving problems A Python programming primer

Daniel Zingaro

Book - 2021

"Teaches readers how to use Python to solve short, situational competitive programming problems. Each chapter requires the reader to learn a new feature or function of Python in order to solve a problem, while emphasizing basic programming concepts, problem-solving strategies, and critical thinking skills"--

Saved in:

2nd Floor Show me where

005.133/PYTHON/Zingaro
1 / 1 copies available
Location Call Number   Status
2nd Floor 005.133/PYTHON/Zingaro Checked In
Subjects
Genres
Handbooks and manuals
Instructional and educational works
Published
San Francisco, CA : No Starch Press [2021]
Language
English
Main Author
Daniel Zingaro (author)
Physical Description
xxviii, 307 pages ; 24 cm
Bibliography
Includes index.
ISBN
9781718501324
  • Acknowledgments
  • Introduction
  • Online Resources
  • Who This Book Is For
  • Why Learn Python?
  • Installing Python
  • Windows
  • macOS
  • Linux
  • How to Read This Book
  • Using Programming Judges
  • Making Your Programming Judge Accounts
  • The DMOJ Judge
  • The Timus Judge
  • The USACO Judge
  • About This Book
  • 1. Getting Started
  • What We'll Be Doing
  • The Python Shell
  • Windows
  • macOS
  • Linux
  • Problem #1. Word Count
  • The Challenge
  • Input
  • Output
  • Strings
  • Representing Strings
  • String Operators
  • String Methods
  • Integer and Floating-Point Numbers
  • Variables
  • Assignment Statement
  • Changing Variable Values
  • Counting the Words Using a Variable
  • Reading Input
  • Writing Output
  • Solving the Problem: A Complete Python Program
  • Launchinq a Text Editor
  • The Program
  • Running the Program
  • Submitting to the Judge
  • Problem #2. Cone Volume
  • The Challenge
  • Input
  • Output
  • More Math in Python
  • Accessing Pi
  • Exponents
  • Converting Between Strings and Integers
  • Solving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • 2. Making Decisions
  • Problem #3. Winning Team
  • The Challenge
  • Input
  • Output
  • Conditional Execution
  • The Boolean Type
  • Relational Operators
  • The if Statement
  • If by Itself
  • If with elif
  • If with else
  • Solving the Problem
  • Problem #4. Telemarketers
  • The Challenge
  • Input
  • Output
  • Boolean Operators
  • Or Operator
  • And Operator
  • Not Operator
  • Solving the Problem
  • Comments
  • Input and Output Redirection
  • Summary
  • Chapter Exercises
  • Notes
  • 3. Repeating Code: Definite Loops
  • Problem #5. Three Cups
  • The Challenge
  • Input
  • Output
  • Why Loops?
  • For Loops
  • Nesting
  • Solving the Problem
  • Problem #6. Occupied Spaces
  • The Challenge
  • Input
  • Output
  • A New Kind of Loop
  • Indexing
  • Range for loops
  • Range for Loops Through Indices
  • Solving the Problem
  • Problem #7. Data Plan
  • The Challenge
  • Input
  • Output
  • Looping to Read Input
  • Solving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • 4. Repeating Code: Indefinite Loops
  • Problem #8. Slot Machines
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • A Limitation of for loops
  • While loops
  • Using while loops
  • Nesting Loops in Loops
  • Adding Boolean Operators
  • Solving the Problem
  • The Mod Operator
  • F-Strings
  • Problem #9. Song Playlist
  • The Challenge
  • Input
  • Output
  • String Slicing
  • Solving the Problem
  • Problem #10. Secret Sentence
  • The Challenge
  • Input
  • Output
  • Another Limitation of for loops
  • While loops Through Indices
  • Solving the Problem
  • Break and continue
  • Break
  • Continue
  • Summary
  • Chapter Exercises
  • Notes
  • 5. Organizing Values Using Lists
  • Problem #11. Village Neighborhood
  • The Challenge
  • Input
  • Output
  • Why Lists?
  • Lists
  • List Mutability
  • Learning About Methods
  • List Methods
  • Adding to a List
  • Sorting a List
  • Removing Values from a List
  • Solving the Problem
  • Avoiding Code Duplication: Two More Solutions
  • Using a Huge Size
  • Building a List of Sizes
  • Problem #12. School Trip
  • The Challenge
  • Input
  • Output
  • A Catch
  • Splitting Strings and Joining Lists
  • Splitting a String into a List
  • Joining a List into a String
  • Changing List Values
  • Solving Most of the Problem
  • Exploring a Test Case
  • The Code
  • How to Handle the Catch
  • Exploring a Test Case
  • More List Operations
  • Finding the Index of the Maximum
  • Solving the Problem
  • Problem #13. Baker Bonus
  • The Challenge
  • Input
  • Output
  • Representing a Table
  • Exploring a Test Case
  • Nested Lists
  • Salving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • 6. Designing Programs With Functions
  • Problem #14. Card Game
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Defining and Calling Functions
  • Functions Without Arguments
  • Functions with Arguments
  • Keyword Arguments
  • Local Variables
  • Mutable Parameters
  • Return Values
  • Function Documentation
  • Solving the Problem
  • Problem #15. Action Figures
  • The Challenge
  • Input
  • Output
  • Representing the Boxes
  • Top-Down Design
  • Doing Top-Down Design
  • The Top Level
  • Task 1. Read Input
  • Task 2. Check Whether All Boxes Are OK
  • Task 3. Obtain a New List of Boxes with Only Left and Right Heights
  • Task A. Sort Boxes
  • Task 5. Determine Whether Boxes Are Organized
  • Putting It All Together
  • Summary
  • Chapter Exercises
  • Notes
  • 7. Reading and Writing Files
  • Problem #16. Essay Formatting
  • The Challenge
  • Input
  • Output
  • Working with Files
  • Opening a File
  • Reading from a File
  • Writing to a File
  • Solving the Problem
  • Exploring a Test Case
  • The Code
  • Problem #17. Form Seeding
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Top-Down Design
  • The Top Level
  • Task 1. Read Input
  • Task 2. Identify Cows
  • Task 3. Eliminate Grass Types
  • Task 4. Choose Smallest-Numbered Grass Type
  • Task 5. Write Output
  • Summary
  • Chapter Exercises
  • Notes
  • 8. Organizing Values Using Sets and Dictionaries
  • Problem #18. Email Addresses
  • The Challenge
  • Input
  • Output
  • Using a List
  • Cleaning an Email Address
  • The Main Program
  • Efficiency of Searching a List
  • Sets
  • Set Methods
  • Efficiency of Searching a Set
  • Solving the Problem
  • Problem #19. Common Words
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Dictionaries
  • Indexing Dictionaries
  • Looping Through Dictionaries
  • Inverting a Dictionary
  • Solving the Problem
  • The Code
  • Adding the Suffix
  • Finding the kth Most Common Words
  • The Main Program
  • Problem #20. Cities and States
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Solving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • 3. Designing Algorithms With Complete Search
  • Problem #21. Lifeguards
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Solving the Problem
  • Firing One Lifeguard
  • The Main Program
  • Efficiency of Our Program
  • Problem #22. Ski Hills
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Solving the Problem
  • Determining the Cost of One Range
  • The Main Program
  • Problem #23. Cow Baseball
  • The Challenge
  • Input
  • Output
  • Using Three Nested Loops
  • The Code
  • Efficiency of Our Program
  • Sorting First
  • The Code
  • Efficiency of Our Program
  • Python Modules
  • The bisect Module
  • Solving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • 10. Big O and Program Efficiency
  • The Problem with Timing
  • Big O
  • Constant Time
  • Linear Time
  • Quadratic Time
  • Cubic Time
  • Multiple Variables
  • Log Time
  • N log n Time
  • Handling Function Calls
  • Summary
  • Problem #24. Longest Scarf
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Algorithm 1
  • Algorithm 2
  • Problem #25. Ribbon Painting
  • The Challenge
  • Input
  • Output
  • Exploring a Test Case
  • Solving the Problem
  • Summary
  • Chapter Exercises
  • Notes
  • Afterword
  • Appendix: Problem Credits
  • Index