Coffee Break Python Workbook
$19.99
Minimum price
$39.99
Suggested price

Coffee Break Python Workbook

127 Python Puzzles to Push You from Zero to Hero in Your Coffee Breaks

About the Book

Puzzle-based Learning Python

This book is the chess grandmaster way of learning Python. It offers you 127 unique and brand-new Python puzzles. Every puzzle points to gaps in your knowledge, challenges you to guess a solution, and then explains potential solutions, in an easy-to-understand manner:

~~~

# Here’s one example puzzle:

my_list = [1, 1, 1, 1]

my_list[1::2] = [2, 3]

print(my_list)

# What’s the output of this code snippet?

~~~

An easy, fun, and effective way of learning Python -- day after day -- in your COFFEE BREAK PYTHON!

Here's what research says about puzzle-based learning:

"Students who were quizzed after studying a short text could recall significantly more information than students who were asked to reread it"

-- Karpicke, 2007, Elsevier Journal of Memory and Language

Practice testing is scientifically proven to generate up to 44% better learning retention and efficiency.

Simply put: quizzes and puzzles work! More than 100,000 Finxters and thousands of "Coffee Break Python" book customers have already successfully improved their skills with code puzzles.

Learning does not happen in a linear and orderly manner. It's a probabilistic, chaotic, and iterative process of creating knowledge gaps in your brain -- and filling them with just the right information you need.

That's the premise of the "Coffee Break Python" textbook series.

What will you get out of the book?

  • Improve your level of deep Python code understanding.
  • Surprise your peers with your newly acquired code speed reading skills.
  • Enjoy the small daily doses of intellectual challenges. A Finxter once called it "Sudoku for coders"! ;)
  • Improve your brain's working memory by hammering down the most important concepts.
  • Learn all the basic Python syntax elements.
  • Discover your own skill level by tracking your puzzle-solving performance.
  • Compare your skill level against other coders: are you a grandmaster of code?
  • Enjoy the fun of rushing over Python -- from "hello world" to "recursive Quicksort".
  • Get the best of all Finxter Python cheat sheets to revive 80% of the Python features in 20% of the time.
  • Get your dream job and rock future code interviews!

And take one step forward mastering the most popular programming language ON THE PLANET!

  • Share this book

  • Categories

    • Python
    • Computers and Programming
    • Computer Science
    • Software
    • Textbooks
  • Feedback

    Email the Author(s)

About the Authors

Christian Mayer
Christian Mayer

Chris is the founder of the programming education company FINXTER, author of the Coffee Break Python series of self-published books, the popular programming book Python One-Liners (NoStarch 2020), a doctorate computer scientist, and owner of one of the top 10 Python blogs worldwide.

His research interests include graph theory and distributed systems.

You can join the FINXTER email academy and consume a large body of free email courses about various topics in computer science and programming.

Lukas Rieger
Lukas Rieger

I love coding and espacially in Python! Python is easy to learn and at the same time it is very powerful. Through the books I would like to help you to discover this! Therefore we designed our puzzle based teaching approach which helps you to learn quickly what you really need and with fun.

I have been working as a Software developer for several years. Currently I'm in the field of operations/SRE of cloud applications.

Bundles that include this book

$184.90
Bought separately
$69.99
Bundle Price
$224.89
Bought separately
$79.99
Bundle Price
$284.87
Bought separately
$99.99
Bundle Price
$99.97
Bought separately
$49.99
Bundle Price
$129.96
Bought separately
$59.99
Bundle Price
$154.91
Bought separately
$59.99
Bundle Price
$298.86
Bought separately
$109.99
Bundle Price
$79.98
Bought separately
$34.99
Bundle Price
$114.92
Bought separately
$49.99
Bundle Price
$254.88
Bought separately
$89.99
Bundle Price

Reader Testimonials

Vlad Bezden, Software engineer
Vlad Bezden, Software engineer

I love it!

Thank you. I love it :) I enjoy reading this book! Keep up the good work.

Albrecht, German Workbook Reader
Albrecht, German Workbook Reader

Great Book!

"A great book, I've learned a lot and marked every​ knowledge gap​ ​[...] Thank you very much!"

Table of Contents

1 Introduction 1

2 A Case for Puzzle-based Learning 5

2.1 Overcome the Knowledge Gap . . . . . . . 6

2.2 Embrace the Eureka Moment . . . . . . . 7

2.3 Divide and Conquer . . . . . . . . . . . . 8

2.4 Improve From Immediate Feedback . . . . 9

2.5 Measure Your Skills . . . . . . . . . . . . . 10

2.6 Individualized Learning . . . . . . . . . . . 12

2.7 Small is Beautiful . . . . . . . . . . . . . . 12

2.8 Active Beats Passive Learning . . . . . . . 14

2.9 Make Code a First-class Citizen . . . . . . 16

2.10 What You See is All There is . . . . . . . 18

3 The Elo Rating for Python 21

3.1 How to Use This Book . . . . . . . . . . . 21

3.2 How to Test and Train Your Skills? . . . . 23

3.3 What Can This Book Do For You? . . . . 27

4 A Quick Overview of the Python Language 31

4.1 Keywords . . . . . . . . . . . . . . . . . . 32

4.2 Basic Data Types . . . . . . . . . . . . . . 35

4.3 Complex Data Types . . . . . . . . . . . . 38

4.4 Classes . . . . . . . . . . . . . . . . . . . . 43

4.5 Functions and Tricks . . . . . . . . . . . . 46

5 Puzzles: Basic to Scholar 51

5.1 Printing values . . . . . . . . . . . . . . . 51

5.2 Basics of variables . . . . . . . . . . . . . . 53

5.3 Getting started with strings . . . . . . . . 54

5.4 Types of variables I . . . . . . . . . . . . . 55

5.5 Types of Variables II . . . . . . . . . . . . 56

5.6 Minimum . . . . . . . . . . . . . . . . . . 57

5.7 String Concatenation . . . . . . . . . . . . 58

5.8 Line Breaks I . . . . . . . . . . . . . . . . 59

5.9 Line Breaks II . . . . . . . . . . . . . . . . 60

5.10 List Length . . . . . . . . . . . . . . . . . 61

5.11 Comparison Operators I . . . . . . . . . . 62

5.12 Comparison Operators II . . . . . . . . . . 63

5.13 Multiple Initializations . . . . . . . . . . . 64

6 Puzzles: Scholar to Intermediate 67

6.1 Maximum . . . . . . . . . . . . . . . . . . 67

6.2 Memory addresses . . . . . . . . . . . . . . 68

6.3 Swapping Values . . . . . . . . . . . . . . 69

6.4 The Boolean Operator AND . . . . . . . . 70

6.5 The Boolean Operator OR . . . . . . . . . 72

6.6 Boolean Operators . . . . . . . . . . . . . 74

6.7 Arithmetic Expressions . . . . . . . . . . . 76

6.8 Integer Division and Modulo . . . . . . . . 78

6.9 Building Strings . . . . . . . . . . . . . . . 80

6.10 The len() Function . . . . . . . . . . . . 81

6.11 String Indices . . . . . . . . . . . . . . . . 82

6.12 The upper() Function . . . . . . . . . . . . 83

6.13 The lower() Function . . . . . . . . . . . . 84

6.14 Somebody Is Shouting . . . . . . . . . . . 85

6.15 Counting Characters . . . . . . . . . . . . 86

6.16 String Lengths . . . . . . . . . . . . . . . 87

6.17 Finding Characters in Strings . . . . . . . 88

6.18 Not Finding Characters in Strings . . . . . 89

6.19 Counting Letters . . . . . . . . . . . . . . 90

6.20 Min() and Max() of a String . . . . . . . . 91

6.21 Reversed Strings . . . . . . . . . . . . . . 92

6.22 String Equality . . . . . . . . . . . . . . . 93

6.23 Slicing I . . . . . . . . . . . . . . . . . . . 95

6.24 Slicing II . . . . . . . . . . . . . . . . . . . 96

6.25 Slicing III . . . . . . . . . . . . . . . . . . 97

6.26 Slicing IV . . . . . . . . . . . . . . . . . . 98

6.27 Slicing V . . . . . . . . . . . . . . . . . . . 99

6.28 Memory Addresses and Slicing . . . . . . . 100

6.29 Accessing List Items I . . . . . . . . . . . 101

6.30 Accessing List Items II . . . . . . . . . . . 103

6.31 List as Stack . . . . . . . . . . . . . . . . . 104

6.32 More String Operations . . . . . . . . . . 105

6.33 Checking for Substrings . . . . . . . . . . 106

6.34 Stripping String Boundaries . . . . . . . . 107

6.35 Strings: Stripping vs. Replacement . . . . 108

6.36 Glueing Strings Together . . . . . . . . . . 109

6.37 The Copy Operation . . . . . . . . . . . . 110

6.38 Growing List Contents I . . . . . . . . . . 111

6.39 Growing List Contents II . . . . . . . . . . 112

6.40 List Operations I . . . . . . . . . . . . . . 114

6.41 List Operations II . . . . . . . . . . . . . . 115

6.42 List Operations III . . . . . . . . . . . . . 116

6.43 List Operations IV . . . . . . . . . . . . . 117

6.44 List Operations V . . . . . . . . . . . . . . 117

6.45 List Operations VI . . . . . . . . . . . . . 118

6.46 List Operations VII . . . . . . . . . . . . . 119

6.47 List Operations VIII . . . . . . . . . . . . 120

6.48 List Operations IX . . . . . . . . . . . . . 121

6.49 List Operations X . . . . . . . . . . . . . . 122

6.50 Lists and the Range Function I . . . . . . 123

6.51 Lists and the Range Function II . . . . . . 124

6.52 Lists and the Range Function III . . . . . 125

6.53 Python’s Multiple Assignment I . . . . . . 126

6.54 Slice Assignments . . . . . . . . . . . . . . 127

6.55 Strings and Lists II . . . . . . . . . . . . . 128

6.56 String Comparisons . . . . . . . . . . . . . 129

6.57 From Booleans to Strings . . . . . . . . . . 130

6.58 Boolean Trickery I . . . . . . . . . . . . . 131

6.59 Boolean Trickery II . . . . . . . . . . . . . 132

6.60 Boolean Trickery III . . . . . . . . . . . . 133

6.61 Looping over Ranges . . . . . . . . . . . . 134

6.62 Reversed Loops . . . . . . . . . . . . . . . 135

6.63 Boolean Trickery IV . . . . . . . . . . . . 136

6.64 Lists and Memory Addresses . . . . . . . . 137

6.65 List Objects . . . . . . . . . . . . . . . . . 138

6.66 Boolean Tricks . . . . . . . . . . . . . . . 139

6.67 Complex Numbers . . . . . . . . . . . . . 140

6.68 Tuples . . . . . . . . . . . . . . . . . . . . 141

6.69 Multiple Assignments . . . . . . . . . . . . 142

6.70 Boolean Integer Conversion . . . . . . . . 143

6.71 The any() Function . . . . . . . . . . . . 144

6.72 The sum() Function . . . . . . . . . . . . 146

6.73 Accessing Complex Numbers . . . . . . . . 148

6.74 Tuple Confusion . . . . . . . . . . . . . . . 149

6.75 Understanding While ... Else (1/3) . . . . 150

6.76 Understanding While ... Else (2/3) . . . . 151

6.77 Understanding While ... Else (3/3) . . . . 153

6.78 Basic Arithmetic . . . . . . . . . . . . . . 155

6.79 Dictionary . . . . . . . . . . . . . . . . . . 156

6.80 Dictionary of Dictionaries . . . . . . . . . 158

6.81 Reverse Dictionary Index . . . . . . . . . . 160

6.82 Default Arguments . . . . . . . . . . . . . 162

7 Puzzles: Intermediate to Professional 165

7.1 Building Strings II . . . . . . . . . . . . . 165

7.2 String: Slicing and Indexing . . . . . . . . 167

7.3 Built-in Python Operations . . . . . . . . 168

7.4 Strings and Lists I . . . . . . . . . . . . . 169

7.5 Formatting Printouts . . . . . . . . . . . . 170

7.6 Floating Point Comparisons . . . . . . . . 172

7.7 Python’s Multiple Assignment II . . . . . 174

7.8 The Not-So-Obvious Case . . . . . . . . . 175

7.9 Rounding Values . . . . . . . . . . . . . . 176

7.10 Initializing Integers . . . . . . . . . . . . . 177

7.11 Basic Typing . . . . . . . . . . . . . . . . 178

7.12 Short Circuiting . . . . . . . . . . . . . . . 179

7.13 While Arithmetic . . . . . . . . . . . . . . 182

7.14 The Lambda Function . . . . . . . . . . . 183

7.15 Zip . . . . . . . . . . . . . . . . . . . . . . 184

7.16 Basic Filtering . . . . . . . . . . . . . . . . 186

7.17 List Comprehension . . . . . . . . . . . . . 188

7.18 Encryption by Obfuscation . . . . . . . . . 190

7.19 String Dictionary . . . . . . . . . . . . . . 193

7.20 Lambda Function . . . . . . . . . . . . . . 194

7.21 Dictionary of Dictionaries . . . . . . . . . 196

7.22 Sorting Dictionary Keys . . . . . . . . . . 198

7.23 Pythonic Loop Iteration . . . . . . . . . . 200

7.24 Filtering with List Comprehension . . . . . 202

7.25 Aggregating with List Comprehension . . . 204

7.26 Maximum of Tuples . . . . . . . . . . . . . 206

7.27 The Key Argument . . . . . . . . . . . . . 208

7.28 Puzzle 123 . . . . . . . . . . . . . . . . . . 210

7.29 Set Operations (1/2) . . . . . . . . . . . . 211

7.30 Set Operations (2/2) . . . . . . . . . . . . 212

7.31 Recursive Algorithm . . . . . . . . . . . . 214

7.32 Fibonacci . . . . . . . . . . . . . . . . . . 218

8 Final Remarks 221

Your skill level . . . . . . . . . . . . . . . 221

Where to go from here? . . . . . . . . . . 222

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub