The Python Quiz Book
The Python Quiz Book
About the Book
Quizzes are a fun way to test your knowledge of something. They make you think. The Python Quiz Book is all about brain teasers for the Python programming language. The Python Quiz Book isn't made to teach you Python. It's there to help you test your knowledge or teach you something new about the language.
The Python Quiz Book has over 100 quizzes! The book will also have a companion course on Teach Me Python.
The goal of the book is to help you be a better engineer. Some of the quizzes will be esoteric or demonstrate bad programming practices. You can learn what not to do in your own code. You will also learn neat tips and tricks about Python that you can share with your friends and coworkers.
Regardless of whether you are a beginner with Python or a seasoned programming rockstar, Michael Driscoll will help you continue to grow in your developer journey. There are hundreds of awesome tutorials on his blog, Mouse Vs Python, that you can read for free!
Table of Contents

Introduction
 Audience
 About the Author
 Conventions
 Book Source Code
 Reader Feedback
 Errata

Quiz 1  Exceptionally Crazy
 The Quiz
 Hint

Answer 1  Exceptionally Crazy
 The Answer
 Explanation

Quiz 2  Number Explosion
 The Quiz
 Hint

Answer 2  Number Explosion
 The Answer
 Explanation

Quiz 3  Letter Explosion
 The Quiz
 Hint

Answer 3  Letter Explosion
 The Answer
 Explanation

Quiz 4  Raising Exceptions
 The Quiz
 Hint

Answer 4  Raising Exceptions
 The Answer
 Explanation

Quiz 5  Positional Arguments
 The Quiz
 Hint

Answer 5  Positional Arguments
 The Answer
 Explanation

Quiz 6  Truthy or Falsey
 The Quiz
 Hint

Answer 6  Truthy or Falsey
 The Answer
 Explanation

Quiz 7  List Popping
 The Quiz
 Hint

Answer 7  List Popping
 The Answer
 Explanation

Quiz 8  Modulo List Comprehension
 The Quiz
 Hint

Answer 8  Modulo List Comprehension
 The Answer
 Explanation

Quiz 9  Zipping Lists
 The Quiz
 Hint

Answer 9  Zipping Lists
 The Answer
 Explanation

Quiz 10  Packing Variables
 The Quiz
 Hint

Answer 10  Packing Variables
 The Answer
 Explanation

Quiz 11  Lambdas and Bools
 The Quiz
 Hint

Answer 11  Lambdas and Bools
 The Answer
 Explanation

Quiz 12  Animaniacal
 The Quiz
 Hint

Answer 12  Animaniacal
 The Answer
 Explanation

Quiz 13  Set Subtraction
 The Quiz
 Hint

Answer 13  Set Subtraction
 The Answer
 Explanation

Quiz 14  Nesting Ternaries
 The Quiz
 Hint

Answer 14  Nesting Ternaries
 The Answer
 Explanation

Quiz 15  Type Multiplication
 The Quiz
 Hint

Answer 15  Type Multiplication
 The Answer
 Explanation

Quiz 16  fstring Formatting
 The Quiz
 Hint

Answer 16  fstring Formatting
 The Answer
 Explanation

Quiz 17  fstrings with Dates
 The Quiz
 Hint

Answer 17  fstrings with Dates
 The Answer
 Explanation

Quiz 18  fstring Rounding
 The Quiz
 Hint

Answer 18  fstring Rounding
 The Answer
 Explanation

Quiz 19  Boolean Math
 The Quiz
 Hint

Answer 19  Boolean Math
 The Answer
 Explanation

Quiz 20  Dictionary Explosion
 The Quiz
 Hint

Answer 20  Dictionary Explosion
 The Answer
 Explanation

Quiz 21  Fun with Walruses
 The Quiz
 Hint

Answer 21  Fun with Walruses
 The Answer
 Explanation

Quiz 22  fstring Justification
 The Quiz
 Hint

Answer 22  fstring Justification
 The Answer
 Explanation

Quiz 23  What’s Callable?
 The Quiz
 Hint

Answer 23  What’s Callable?
 The Answer
 Explanation

Quiz 24  Shadows
 The Quiz
 Hint

Answer 24  Shadows
 The Answer
 Explanation

Quiz 25  Dictionary Keys
 The Quiz
 Hint

Answer 25  Dictionary Keys
 The Answer
 Explanation

Quiz 26  List Mutation
 The Quiz
 Hint

Answer 26  List Mutation
 The Answer
 Explanation

Quiz 27  fstring Number Bases
 The Quiz
 Hint

Quiz 28  Boolean Shenanigans
 The Quiz
 Hint

Answer 28  Boolean Shenanigans
 The Answer
 Explanation

Quiz 29  String Slicing Silliness
 The Quiz
 Hint

Answer 29  String Slicing Silliness
 The Answer
 Explanation

Quiz 30  Enumerate and Dictionaries
 The Quiz
 Hint

Quiz 31  Dynamic Docstrings
 The Quiz
 Hint

Answer 31  Dynamic Docstrings
 The Answer
 Explanation

Quiz 32  Magical Multiplication
 The Quiz
 Hint

Answer 32  Magical Multiplication
 The Answer
 Explanation

Quiz 34  What Makes a Function?
 The Quiz
 Hint

Answer 34  What Makes a Function?
 The Answer
 Explanation

Quiz 35  More Fun with Walruses
 The Quiz
 Hint

Answer 35  More Fun with Walruses
 The Answer
 Explanation

Quiz 36  Dictionary Comprehension Trickery
 The Quiz
 Hint

Answer 36  Dictionary Comprehension Trickery
 The Answer
 Explanation

Quiz 37  Multiple Assignment Mania
 The Quiz
 Hint

Answer 37  Multiple Assignment Mania
 The Answer
 Explanation

Quiz 38  Exhausting Generators
 The Quiz
 Hint

Answer 38  Exhausting Generators
 The Answer
 Explanation

Quiz 39  A List O’ Functions
 The Quiz

Answer 39  A List O’ Functions
 Explanation

Quiz 40  Fixing the Math
 The Quiz
 Hint

Answer 40  Fixing the Math
 The Answer
 Explanation

Quiz 41  Runaway Characters
 The Quiz
 Hint

Answer 41  Runaway Characters
 The Answer
 Explanation

Quiz 42  Truthy or Falsey Take Two
 The Quiz
 Hint

Answer 42  Truthy or Falsey Take Two
 The Answer
 Explanation

Quiz 43  More fstring Formatting Fun
 The Quiz
 Hint

Answer 43  More fstring Formatting Fun
 The Answer
 Explanation

Quiz 44  Fun with Types
 The Quiz
 Hint

Answer 44  Fun with Types
 The Answer
 Explanation

Quiz 45  Boolean Equality
 The Quiz
 Hint

Answer 45  Boolean Equality
 The Answer
 Explanation

Quiz 46  Manic Multistring
 The Quiz
 Hint

Answer 46  Manic Multistring
 The Answer
 Explanation
The Leanpub 60day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$12,124,424writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
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 inprogress, 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 copyprotection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Mastering STM32  Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM CortexM platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Functional Programming Made Easier
Charles ScalfaniA Functional Programming book from beginner to advanced without skipping a single step along the way.
In my 40 years of programming, I've felt that programming books always let me down, especially Functional Programming books. So, I wrote the book I wish I had 5 years ago.
Functional Programming will never be easy, but it can be easier.
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industryleading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Windows 11 Field Guide
Rafael Rivera and Paul ThurrottThe Windows 11 Field Guide is a fulllength ebook about the latest version of Microsoft Windows, aimed at those users who will upgrade from Windows 10 or acquire Windows 11 with a new PC.
nodeopcua by example
Etienne RossignonGet the best out of nodeopcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
C++20  The Complete Guide
Nicolai M. JosuttisIntroducing EventStorming
Alberto BrandoliniThe deepest tutorial and explanation about EventStorming, straight from the inventor.
NodeOPCUA by example  edition 2022
Etienne RossignonGet the best out of nodeopcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
Functional EventDriven Architecture
Gabriel VolpeExplore the eventdriven architecture (EDA) in a purely functional way. Learn to design and develop distributed systems that scale. Identify common design patterns in such systems.
Take your functional programming skills to the next level by joining me in developing a distributed system powered by Apache Pulsar and Fs2 streams, all in Scala 3!
Top Bundles
 #1
1500 QUIZ COMMENTATI (3 libri)
3 Books
Tre libri dei QUIZ MMG Commentati al prezzo di DUE! I QUIZ dei concorsi ufficiali di Medicina Generale relativi agli anni: 2000200120032012201320142015201620172018201920202021 +100 inediti Raccolti in unico bundle per aiutarvi nello studio e nella preparazione al concorso. All'interno di ogni libro i quiz sono stati suddivisi per...  #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification...  #3
PatternOriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible...  #4
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...  #6
The Python Craftsman
3 Books
The Python Craftsman series comprises The Python Apprentice, The Python Journeyman, and The Python Master. The first book is primarily suitable for programmers with some experience of programming in another language. If you don't have any experience with programming this book may be a bit daunting. You'll be learning not just a programming...  #10
Statistics  All Lee Baker's Books
10 Books
This bundle includes all of the statistics books that Lee Baker has published at LeanPub 13 Statistics Books*1 PlaceNo Hassle! All in both epub and mobi formats  perfect for all devices and screen sizes.  *The book listed as Getting Started With Statistics is a bundle of 4 books...