The Python Quiz Book
$29.99
Minimum price
$35.00
Suggested price

The Python Quiz Book

About the Book

Test your Python programming language the fun way… Rather than making annoying mistakes in your code!

The Python Quiz Book does exactly what it says on the cover. It is packed with intriguing brainteasers that will have beginners to advanced programmers scratching their craniums... This book will help you become a better engineer!

Some of the quizzes are esoteric or show bad programming practices. You benefit from learning what not to do in your code. Moreover, the book also contains a plethora of hints and tips about python that will make your programming life much easier.

The Python Quiz book has over 100 quizzes with each one offering you vital learning points on programming with Python like a pro.

Give your brain a workout today and grab the Python Quiz book now!

About the Author

Michael Driscoll
Michael Driscoll

Michael has been programming with Python since 2006. He is the author of the popular Python blog, The Mouse Vs. the Python. Michael has been a technical reviewer for Packt Publishing and No Starch Press.  He is also a contributor on Real Python.

He also co-authored The Essential Core Python Cheat Sheet for DZone.

Michael released his first book, Python 101, June 3rd, 2014. He wrote the follow up, Python 201: Intermediate Python and published it in the summer of 2016. He is also the author of wxPython Cookbook from Apress as well as Python Interviews from Packt Publishing.

Michael is currently working on some new books as well.

Table of Contents

    • About the Technical Reviewer
      • Ethan Furman
    • Acknowledgments
    • 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 - Type Addition
      • The Quiz
      • Hint
    • Answer 4 - Type Addition
      • 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 - f-string Formatting
      • The Quiz
      • Hint
    • Answer 16 - f-string Formatting
      • The Answer
      • Explanation
    • Quiz 17 - f-strings with Dates
      • The Quiz
      • Hint
    • Answer 17 - f-strings with Dates
      • The Answer
      • Explanation
    • Quiz 18 - f-string Rounding
      • The Quiz
      • Hint
    • Answer 18 - f-string 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 - f-string Justification
      • The Quiz
      • Hint
    • Answer 22 - f-string 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 - f-string Number Bases
      • The Quiz
      • Hint
    • Answer 27 - f-string Number Bases
      • The Answer
      • Explanation
    • 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
    • Answer 30 - Enumerate and Dictionaries
      • The Answer
      • Explanation
    • 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 33 - Deranged Generators
      • The Quiz
      • Hint
    • Answer 33 - Deranged Generators
      • 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
      • Hint
    • Answer 39 - A List O’ Functions
      • The Answer
      • 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 f-string Formatting Fun
      • The Quiz
      • Hint
    • Answer 43 - More f-string 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
    • Quiz 47 - Slicing and Dicing
      • The Quiz
      • Hint
    • Answer 47 - Slicing and Dicing
      • The Answer
      • Explanation
    • Quiz 48 - Text Finding Adventures
      • The Quiz
      • Hint
    • Answer 48 - Text Finding Adventures
      • The Answer
      • Explanation
    • Quiz 49 - Puzzling Shadows
      • The Quiz
      • Hint
    • Answer 49 - Puzzling Shadows
      • The Answer
      • Explanation
    • Quiz 50 - A Print Puzzle
      • The Quiz
      • Hint
    • Answer 50 - A Print Puzzle
      • The Answer
      • Explanation
    • Quiz 51 - The Ellipsis Condition
      • The Quiz
      • Hint
    • Answer 51 - The Ellipsis Condition
      • The Answer
      • Explanation
    • Quiz 52 - Exceptionally Crazy Again
      • The Quiz
      • Hint
    • Answer 52 - Exceptionally Crazy Again
      • The Answer
      • Explanation
    • Quiz 53 - Crazy Mixed Up Code
      • The Quiz
      • Hint
    • Answer 53 - Crazy Mixed Up Code
      • The Answer
      • Explanation
    • Quiz 54 - Return vs. Yield
      • The Quiz
      • Hint
    • Answer 54 - Return vs. Yield
      • The Answer
      • Explanation
    • Quiz 55 - More Shadows
      • The Quiz
      • Hint
    • Answer 55 - More Shadows
      • The Answer
      • Explanation
    • Quiz 56 - The Scope of the Matter
      • The Quiz
      • Hint
    • Answer 56 - The Scope of the Matter
      • The Answer
      • Explanation
    • Quiz 58 - Tuple Augmented Assignment
      • The Quiz
      • Hint
    • Answer 58 - Tuple Augmented Assignment
      • The Answer
      • Explanation
    • Quiz 59 - Exception Shadowing
      • The Quiz
      • Hint
    • Answer 59 - Exception Shadowing
      • The Answer
      • Explanation
    • Quiz 60 - Subclassing Silliness
      • The Quiz
      • Hint
    • Answer 60 - Subclassing Silliness
      • The Answer
      • Explanation
    • Quiz 61 - Loopy Variables
      • The Quiz
      • Hint
    • Answer 61 - Loopy Variables
      • The Answer
      • Explanation
    • Quiz 62 - More Loopy Variables
      • The Quiz
      • Hint
    • Answer 62 - More Loopy Variables
      • The Answer
      • Explanation
    • Quiz 63 - Dictionary Madness
      • The Quiz
      • Hint
    • Answer 63 - Dictionary Madness
      • The Answer
      • Explanation
    • Quiz 64 - Silly Lists
      • The Quiz
      • Hint
    • Answer 64 - Silly Lists
      • The Answer
      • Explanation
    • Quiz 65 - Modifying Lists
      • The Quiz
      • Hint
    • Answer 65 - Modifying Lists
      • The Answer
      • Explanation
    • Quiz 66 - Garbage Collection
      • The Quiz
      • Hint
    • Answer 66 - Garbage Collection
      • The Answer
      • Explanation
    • Quiz 67 - Details Matter
      • The Quiz
      • Hint
    • Answer 67 - Details Matter
      • The Answer
      • Explanation
    • Quiz 68 - Range Rules
      • The Quiz
      • Hint
    • Answer 68 - Range Rules
      • The Answer
      • Explanation
    • Quiz 69 - Integer Identity
      • The Quiz
      • Hint
    • Answer 69 - Integer Identity
      • The Answer
      • Explanation
    • Quiz 70 - List Insanity
      • The Quiz
      • Hint
    • Answer 70 - List Insanity
      • The Answer
      • Explanation
    • Quiz 71 - Enumerate Enigma
      • The Quiz
      • Hint
    • Answer 71 - Enumerate Enigma
      • The Answer
      • Explanation
    • Quiz 72 - Walrus Comprehensions
      • The Quiz
      • Hint
    • Answer 72 - Walrus Comprehensions
      • The Answer
      • Explanation
    • Quiz 73 - Indexing Indignation
      • The Quiz
      • Hint
    • Answer 73 - Indexing Indignation
      • The Answer
      • Explanation
    • Quiz 74 - List Defaults
      • The Quiz
      • Hint
    • Answer 74 - List Defaults
      • The Answer
      • Explanation
    • Quiz 75 - Counting Letters
      • The Quiz
      • Hint
    • Answer 75 - Counting Letters
      • The Answer
      • Explanation
    • Quiz 76 - Veritable Variables
      • The Quiz
      • Hint
    • Answer 76 - Veritable Variables
      • The Answer
      • Explanation
    • Quiz 77 - Tuples Are Immutable!
      • The Quiz
      • Hint
    • Answer 77 - Tuples Are Immutable!
      • The Answer
      • Explanation
    • Quiz 78 - Tuple Addition
      • The Quiz
      • Hint
    • Answer 78 - Tuple Addition
      • The Answer
      • Explanation
    • Quiz 79 - Exacerbated Exceptions
      • The Quiz
      • Hint
    • Answer 79 - Exacerbated Exceptions
      • The Answer
      • Explanation
    • Quiz 80 - Tuple Enumeration
      • The Quiz
      • Hint
    • Answer 80 - Tuple Enumeration
      • The Answer
      • Explanation
    • Quiz 81 - Lists and Strings
      • The Quiz
      • Hint
    • Answer 81 - Lists and Strings
      • The Answer
      • Explanation
    • Quiz 82 - Multireference Anarchy
      • The Quiz
      • Hint
    • Answer 82 - Multireference Anarchy
      • The Answer
      • Explanation
    • Quiz 83 - Tuples and Dictionaries
      • The Quiz
      • Hint
    • Answer 83 - Tuples and Dictionaries
      • The Answer
      • Explanation
    • Quiz 84 - Ridiculous Rounding
      • The Quiz
      • Hint
    • Answer 84 - Ridiculous Rounding
      • The Answer
      • Explanation
    • Quiz 85 - Conditional Unpacking
      • The Quiz
      • Hint
    • Answer 85 - Conditional Unpacking
      • The Answer
      • Explanation
    • Quiz 87 - List Addition
      • The Quiz
      • Hint
    • Answer 87 - List Addition
      • The Answer
      • Explanation
    • Quiz 88 - Essential Assertions
      • The Quiz
      • Hint
    • Answer 88 - Essential Assertions
      • The Answer
      • Explanation
    • Quiz 89 - String Silliness
      • The Quiz
      • Hint
    • Answer 89 - String Silliness
      • The Answer
      • Explanation
    • Quiz 90 - List Insertion
      • The Quiz
      • Hint
    • Answer 90 - List Insertion
      • The Answer
      • Explanation
    • Quiz 91 - Letter Splitting
      • The Quiz
      • Hint
    • Answer 91 - Letter Splitting
      • The Answer
      • Explanation
    • Quiz 92 - Class Attributes
      • The Quiz
      • Hint
    • Answer 92 - Class Attributes
      • The Answer
      • Explanation
    • Quiz 93 - Class For Loop
      • The Quiz
      • Hint
    • Answer 93 - Class For Loop
      • The Answer
      • Explanation
    • Quiz 94 - The Length of a Split
      • The Quiz
      • Hint
    • Answer 94 - The Length of a Split
      • The Answer
      • Explanation
    • Quiz 95 - Senseless Sorting
      • The Quiz
      • Hint
    • Answer 95 - Senseless Sorting
      • The Answer
      • Explanation
    • Quiz 96 - Eclectic Ellipses
      • The Quiz
      • Hint
    • Answer 96 - Eclectic Ellipses
      • The Answer
      • Explanation
    • Quiz 98 - Diabolical Decorator
      • The Quiz
      • Hint
    • Answer 98 - Diabolical Decorator
      • The Answer
      • Explanation
    • Quiz 99 - Tuple Comparison
      • The Quiz
      • Hint
    • Answer 99 - Tuple Comparison
      • The Answer
      • Explanation
    • Quiz 100 - Idiomatic Inheritance
      • The Quiz
      • Hint
    • Answer 100 - Idiomatic Inheritance
      • The Answer
      • Explanation
    • Quiz 101 - Maniacal Munging
      • The Quiz
      • Hint
    • Answer 101 - Maniacal Munging
      • The Answer
      • Explanation
    • Quiz 102 - Plonking Pinnipeds
      • The Quiz
      • Hint
    • Answer 102 - Plonking Pinnipeds
      • The Answer
      • Explanation
    • Quiz 103 - Dataclass Difficulties
      • The Quiz
      • Hint
    • Answer 103 - Dataclass Difficulties
      • The Answer
      • Explanation
    • Quiz 104 - Cascading Comparisons
      • The Quiz
      • Hint
    • Answer 104 - Cascading Comparisons
      • The Answer
      • Explanation
    • Quiz 105 - Methods Into Attributes
      • The Quiz
      • Hint
    • Answer 105 - Methods Into Attributes
      • The Answer
      • Explanation
    • Quiz 106 - Hello World
      • The Quiz
      • Hint
    • Answer 106 - Hello World
      • The Answer
      • Explanation
    • Quiz 107 - String Methodology
      • The Quiz
      • Hint
    • Answer 107 - String Methodology
      • The Answer
      • Explanation
    • Quiz 108 - Matching Mayhem
      • The Quiz
      • Hint
    • Answer 108 - Matching Mayhem
      • The Answer
      • Explanation
    • Quiz 109 - Unruly Unpacking
      • The Quiz
      • Hint
    • Answer 109 - Unruly Unpacking
      • The Answer
      • Explanation
    • Quiz 110 - Sorting Shutout
      • The Quiz
      • Hint
    • Answer 110 - Sorting Shutout
      • The Answer
      • Explanation
    • Afterword

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...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book 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