Kick off your book project in 2 hours, get started with GhostAI in 2 hours, or do both! Free live workshops, on Zoom. You’ll leave with a real book project and a clear plan to keep going. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Ten Essays on Fizz Buzz

Meditations on Python, mathematics, science, engineering, and design

Over the years I have invented and/or collected various clever and/or stupid ways of solving Fizz Buzz. In this book are ten solutions I found particularly interesting, each one the inspiration for a discussion of different aspects of coding, Python, testing, Fizz Buzz, mathematics, software design, technical interviewing, and related topics.

最低售价

$14.95

$19.95

支付金额

作者利润

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
关于

关于

关于本书

"This book is so good. I wish I'd written it." -- Tim Hopper (@tdhopper)

"Highly recommended: a grand tour of computer science theory and practical software engineering, explored through the lens of 10 Fizz Buzz solutions in Python. Outstanding." -- Paco Nathan (@pacoid)

"I'd never have thought a book about Fizz Buzz would make me a better programmer, but I was wrong. Joel in the course of 10 chapters does a broad survey of core Python concepts, software design and testing, mathematics, and more (including deep learning) using Fizz Buzz as the guiding example. It's that rare technical book that remains engaging, entertaining, and accessible." -- Binal Patel (@binalkp91)

More real Python tips than any "Python tricks" book! From a Python beginner to an experienced ML practitioner, you're bound to learn something about the language and its application to a progressive level of algorithmic applications. Recommended for the anyone looking to "level up" their Python or problem solving skills! -- Tom Marthaler (@tmarthal)

Fizz Buzz is the following (simple) problem:

Print the numbers from 1 to 100, except that if the number is divisible by 3, instead print "fizz"; if the number is divisible by 5, instead print "buzz"; and if the number is divisible by 15, instead print "fizzbuzz".

It originated as a children's game, but has since taken on a new life as a lowest-common-denominator litmus test for assessing computer programmers.

If you are an experienced programmer, it is an extremely easy problem to solve. Because of this, it has taken on a third life as the prototypical bad interview problem. Everyone knows that it's the question you ask people to make sure that they're not completely incompetent as programmers. Accordingly, if your interviewer asks you to solve it, he's suggesting he thinks it possible that you're completely incompetent as a programmer. You would not be wrong to feel insulted!

My association with this problem began in 2016, when I wrote a blog post called Fizz Buzz in Tensorflow, the (possibly fictional) story of one such insulted programmer who decided to show up his interviewer by approaching Fizz Buzz as a deep learning problem. This post went modestly viral, and ever since then I have been seen as a thought leader in the Fizz Buzz space.

Accordingly, over the years I have come up with and/or collected various other stupid and/or clever ways of solving Fizz Buzz. I have not blogged about them, as I am not the sort of person who beats a joke to death, but occasionally I will tweet about them, and recently in response someone suggested that I write a book on "100 Ways of Writing Fizz Buzz in Python."

Now, I could probably come up with 100 ways of solving Fizz Buzz, but most of them would not be very interesting. Luckily for you, I was able to come up with 10 that are interesting in various ways, each of which turned out to be a good launching-off point for (sometimes meandering) discussions of various aspects of coding, Python, Fizz Buzz, mathematics, software design, technical interviewing, and various other topics.

Hence "Ten Essays on Fizz Buzz".

In many ways this is a strange book. Its goal is not to teach you a specific field or a specific technology. I hope you will learn a lot from reading it, but it's not really a book that you'd read in order to learn anything in particular. Most technical books are about specific technical topics; this one sort of isn't.

Nonetheless, it is a technical book. Each essay contains code that implements a different solution of Fizz Buzz. Each essay uses code to illustrate its ideas. Each essay represents my current best thinking about how to solve problems using code. If you have a coding job, you should feel no reluctance to expense this book to your employer.

As I primarily code in Python, all of these solutions will be in Python. Some of them will use features that were only introduced in Python 3.6, and some of them will demonstrate concepts and techniques that are mostly specific to Python. On some level this is deeply a Python book. However, my goal was to write a book that would be interesting and enlightening even if you are not a Python programmer. I'll leave it to you to judge how successful I was.

作者

关于作者们

Joel Grus

Joel Grus is the creator of the beloved book Data Science from Scratch, the beloved blog post Fizz Buzz in Tensorflow, and the polarizing JuypterCon presentation I Don't Like Notebooks.

He's also the co-host of the Adversarial Learning podcast.

He very occasionally blogs at joelgrus.com, very occasionally records livecoding videos, and spends most of the rest of his time on Twitter @joelgrus.

If you'd like to keep up with his various activities, thoughts, and projects, you can sign up for his mailing list.

Leanpub Podcast

Episode 181

An Interview with Joel Grus

目录

目录

Introduction

1.100 Print Statements

  1. Algorithm and Abstraction
  2. Reusability and Changeability
  3. Testability and Fizz Buzz
  4. Testability Beyond Fizz Buzz
  5. Generating the print Statements

2.if / elif / elif / else

  1. Mind the Order
  2. Divisibility and Modulus
  3. “We’re Adders, We Need Logs to Multiply”
  4. Some Other Checks
  5. Some Well-Known Tricks
  6. Eliminating elif

3.The Cycle of 15

  1. Equivalence Classes
  2. None as a Sentinel
  3. Truthiness and Logic
  4. dict.get

4.Euclid’s Solution

  1. Prime Numbers
  2. Performance Optimization
  3. Factorization
  4. What Prime Factorization Has to Do with Fizz Buzz
  5. Greatest Common Divisors and Least Common Multiples
  6. gcd and Fizz Buzz
  7. Euclid’s Algorithm

5.Trigonometry

  1. Sin and Cos
  2. int
  3. Pi and Tau
  4. Operator Overload

6.A Big Number

  1. Decimal, Binary, and Hexadecimal
  2. A Secret Encoding
  3. Prefix Codes
  4. Huffman Coding
  5. Data Modeling
  6. Our Data Model
  7. Constructing the Code
  8. Digression: Mutable Default Values
  9. Digression: heapq
  10. Decoding
  11. “Accidentally Quadratic”
  12. Regular Expressions

7.Infinite Iterables

  1. Iterables, Iterators, and Lazy Infinite Sequences
  2. itertools
  3. zip vs map
  4. Putting It All Together
  5. Bonus: PowerFizz

8.Random Guessing

  1. random
  2. Pseudorandomness and the Seed
  3. Creating a Pseudorandom Generator
  4. Advances in the Same Iterator
  5. Values and References
  6. Argument Unpacking
  7. The Cycle of 15, Redux
  8. Where did 23_977_775 come from?
  9. Putting it all together

9.Matrix Multiplication

  1. n-Dimensional Arrays
  2. Digression: Recursion, Iteration, and Tail Recursion
  3. NumPy
  4. Working With Arrays
  5. Fizz Buzz as a Matrix Multiplication Problem
  6. How Did I Choose Those Weights?

10.Fizz Buzz in Tensorflow

  1. Machine Learning
  2. Fizz Buzz as a Machine Learning Problem
  3. Learning and Generalization
  4. Feature Engineering
  5. Deep Learning
  6. Validation
  7. How Does It Work?

About the Author

Acknowledgements

获取免费样章

Click the buttons to the right to get the free sample in PDF or EPUB, or read the sample online here

Leanpub 无条件、零风险的100%满意保证

支付后的60天内,只需简单点击两下,您便可以退书并且取回先前支付的全部金额
查看完整条款

在10美元的购买中赚取8美元,在20美元的购买中赚取16美元

我们在7.99美元或以上的购买中支付80%的版税,在0.99美元到7.98美元之间的购买中支付80%的版税减去0.5美元固定费用在10美元的销售中您可赚取8美元,在20美元的销售中可赚取16美元。因此,如果我们以20美元的价格售出5000本未退款的图书,您将赚取80,000美元

(是的,一些作者在Leanpub上已经赚取了远超过这个数额的收入。)

事实上,作者们通过在Leanpub上写作、出版和销售已经赚取了超过1400万美元

了解更多关于在Leanpub上写作的信息

免费更新。无DRM。

如果你购买了Leanpub的书,只要作者更新这本书,你就可以免费获得更新!许多作者使用Leanpub在他们编写书籍的过程中发布他们的作品。所有读者都可以获得免费更新,无论他们何时购买的书或他们支付了多少钱(包括免费)。

大多数Leanpub书籍都提供PDF(适用于计算机)、EPUB(适用于手机和平板电脑)和MOBI(适用于Kindle)格式。书籍包含的格式会显示在此页面的右上角。

最后,Leanpub的书籍没有任何DRM版权保护的限制,所以你可以轻松地在任何支持的设备上阅读它们。

了解更多关于Leanpub的电子书格式以及在哪里阅读它们

在 Leanpub 上写作和出版

作者与出版社使用 Leanpub 来出版正在写作中和已完成的书籍,就像这本书一样。你也可以使用 Leanpub 来撰写、出版和销售你的作品!Leanpub 是功能强大的平台,非常适合认真的作者。它结合了简单、优雅的写作与出版流程,以及一个可销售正在写作中的电子书的线上商店。Leanpub 是作家的神奇之笔:只需编写纯文本,然后点击按钮即可出版你的电子书。真的就是这么简单。

学习更多关于在 Leanpub 上写作的信息