The Python Quiz Book Michael Driscoll Full Chapter

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

The Python Quiz Book Michael Driscoll

Visit to download the full and correct content document:


https://ebookmass.com/product/the-python-quiz-book-michael-driscoll/
The Python Quiz Book
Michael Driscoll
This book is for sale at http://leanpub.com/pyquiz

This version was published on 2023-02-15

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and
many iterations to get reader feedback, pivot until you have the right book and build traction once
you do.

© 2022 - 2023 Michael Driscoll


Tweet This Book!
Please help Michael Driscoll by spreading the word about this book on Twitter!
The suggested hashtag for this book is #PythonQuizBook.
Find out what other people are saying about the book by clicking on this link to search for this
hashtag on Twitter:
#PythonQuizBook
Contents

About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


Ethan Furman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

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

Quiz 1 - Exceptionally Crazy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Answer 1 - Exceptionally Crazy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Quiz 2 - Number Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Answer 2 - Number Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Quiz 3 - Letter Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Answer 3 - Letter Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
CONTENTS

Quiz 4 - Type Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Answer 4 - Type Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Quiz 5 - Positional Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Answer 5 - Positional Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Quiz 6 - Truthy or Falsey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Answer 6 - Truthy or Falsey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Quiz 7 - List Popping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Answer 7 - List Popping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Quiz 8 - Modulo List Comprehension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Answer 8 - Modulo List Comprehension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Quiz 9 - Zipping Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Answer 9 - Zipping Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CONTENTS

Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Quiz 10 - Packing Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Answer 10 - Packing Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Quiz 11 - Lambdas and Bools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Answer 11 - Lambdas and Bools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Quiz 12 - Animaniacal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Answer 12 - Animaniacal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Quiz 13 - Set Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Answer 13 - Set Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Quiz 14 - Nesting Ternaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Answer 14 - Nesting Ternaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Quiz 15 - Type Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
CONTENTS

Answer 15 - Type Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Quiz 16 - f-string Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Answer 16 - f-string Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Quiz 17 - f-strings with Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

Answer 17 - f-strings with Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Quiz 18 - f-string Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Answer 18 - f-string Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Quiz 19 - Boolean Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Answer 19 - Boolean Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Quiz 20 - Dictionary Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Answer 20 - Dictionary Explosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Quiz 21 - Fun with Walruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
CONTENTS

Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Answer 21 - Fun with Walruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Quiz 22 - f-string Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Answer 22 - f-string Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Quiz 23 - What’s Callable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Answer 23 - What’s Callable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Quiz 24 - Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Answer 24 - Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Quiz 25 - Dictionary Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Answer 25 - Dictionary Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Quiz 26 - List Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Answer 26 - List Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
CONTENTS

Quiz 27 - f-string Number Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Answer 27 - f-string Number Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Quiz 28 - Boolean Shenanigans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

Answer 28 - Boolean Shenanigans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Quiz 29 - String Slicing Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

Answer 29 - String Slicing Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Quiz 30 - Enumerate and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

Answer 30 - Enumerate and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Quiz 31 - Dynamic Docstrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Answer 31 - Dynamic Docstrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

Quiz 32 - Magical Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Answer 32 - Magical Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
CONTENTS

Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

Quiz 33 - Deranged Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

Answer 33 - Deranged Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Quiz 34 - What Makes a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Answer 34 - What Makes a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

Quiz 35 - More Fun with Walruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

Answer 35 - More Fun with Walruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Quiz 36 - Dictionary Comprehension Trickery . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Answer 36 - Dictionary Comprehension Trickery . . . . . . . . . . . . . . . . . . . . . . . . . . 108


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Quiz 37 - Multiple Assignment Mania . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Answer 37 - Multiple Assignment Mania . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

Quiz 38 - Exhausting Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
CONTENTS

Answer 38 - Exhausting Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Quiz 39 - A List O’ Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Answer 39 - A List O’ Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Quiz 40 - Fixing the Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Answer 40 - Fixing the Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

Quiz 41 - Runaway Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

Answer 41 - Runaway Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Quiz 42 - Truthy or Falsey Take Two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

Answer 42 - Truthy or Falsey Take Two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

Quiz 43 - More f-string Formatting Fun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

Answer 43 - More f-string Formatting Fun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Quiz 44 - Fun with Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
CONTENTS

Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Answer 44 - Fun with Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Quiz 45 - Boolean Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Answer 45 - Boolean Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Quiz 46 - Manic Multistring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

Answer 46 - Manic Multistring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Quiz 47 - Slicing and Dicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

Answer 47 - Slicing and Dicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

Quiz 48 - Text Finding Adventures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

Answer 48 - Text Finding Adventures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Quiz 49 - Puzzling Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

Answer 49 - Puzzling Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
CONTENTS

Quiz 50 - A Print Puzzle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

Answer 50 - A Print Puzzle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

Quiz 51 - The Ellipsis Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Answer 51 - The Ellipsis Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

Quiz 52 - Exceptionally Crazy Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

Answer 52 - Exceptionally Crazy Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Quiz 53 - Crazy Mixed Up Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Answer 53 - Crazy Mixed Up Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Quiz 54 - Return vs. Yield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

Answer 54 - Return vs. Yield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

Quiz 55 - More Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

Answer 55 - More Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
CONTENTS

Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Quiz 56 - The Scope of the Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Answer 56 - The Scope of the Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

Quiz 58 - Tuple Augmented Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Answer 58 - Tuple Augmented Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Quiz 59 - Exception Shadowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

Answer 59 - Exception Shadowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

Quiz 60 - Subclassing Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

Answer 60 - Subclassing Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

Quiz 61 - Loopy Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Answer 61 - Loopy Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Quiz 62 - More Loopy Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
CONTENTS

Answer 62 - More Loopy Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

Quiz 63 - Dictionary Madness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

Answer 63 - Dictionary Madness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

Quiz 64 - Silly Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

Answer 64 - Silly Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

Quiz 65 - Modifying Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

Answer 65 - Modifying Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Quiz 66 - Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

Answer 66 - Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

Quiz 67 - Details Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

Answer 67 - Details Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

Quiz 68 - Range Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
CONTENTS

Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

Answer 68 - Range Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

Quiz 69 - Integer Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Answer 69 - Integer Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

Quiz 70 - List Insanity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

Answer 70 - List Insanity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Quiz 71 - Enumerate Enigma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Answer 71 - Enumerate Enigma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

Quiz 72 - Walrus Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Answer 72 - Walrus Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

Quiz 73 - Indexing Indignation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

Answer 73 - Indexing Indignation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
CONTENTS

Quiz 74 - List Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Answer 74 - List Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

Quiz 75 - Counting Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

Answer 75 - Counting Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Quiz 76 - Veritable Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

Answer 76 - Veritable Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

Quiz 77 - Tuples Are Immutable! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

Answer 77 - Tuples Are Immutable! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

Quiz 78 - Tuple Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

Answer 78 - Tuple Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

Quiz 79 - Exacerbated Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

Answer 79 - Exacerbated Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
CONTENTS

Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

Quiz 80 - Tuple Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

Answer 80 - Tuple Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

Quiz 81 - Lists and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

Answer 81 - Lists and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

Quiz 82 - Multireference Anarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

Answer 82 - Multireference Anarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

Quiz 83 - Tuples and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Answer 83 - Tuples and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

Quiz 84 - Ridiculous Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

Answer 84 - Ridiculous Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

Quiz 85 - Conditional Unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
CONTENTS

Answer 85 - Conditional Unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

Quiz 87 - List Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

Answer 87 - List Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

Quiz 88 - Essential Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

Answer 88 - Essential Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

Quiz 89 - String Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

Answer 89 - String Silliness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

Quiz 90 - List Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

Answer 90 - List Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

Quiz 91 - Letter Splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

Answer 91 - Letter Splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Quiz 92 - Class Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
CONTENTS

Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

Answer 92 - Class Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Quiz 93 - Class For Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

Answer 93 - Class For Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Quiz 94 - The Length of a Split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

Answer 94 - The Length of a Split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

Quiz 95 - Senseless Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

Answer 95 - Senseless Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Quiz 96 - Eclectic Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

Answer 96 - Eclectic Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Quiz 98 - Diabolical Decorator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Answer 98 - Diabolical Decorator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
CONTENTS

Quiz 99 - Tuple Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

Answer 99 - Tuple Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

Quiz 100 - Idiomatic Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Answer 100 - Idiomatic Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

Quiz 101 - Maniacal Munging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

Answer 101 - Maniacal Munging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

Quiz 102 - Plonking Pinnipeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

Answer 102 - Plonking Pinnipeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

Quiz 103 - Dataclass Difficulties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

Answer 103 - Dataclass Difficulties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Quiz 104 - Cascading Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

Answer 104 - Cascading Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
CONTENTS

Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

Quiz 105 - Methods Into Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

Answer 105 - Methods Into Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

Quiz 106 - Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

Answer 106 - Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Quiz 107 - String Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

Answer 107 - String Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

Quiz 108 - Matching Mayhem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

Answer 108 - Matching Mayhem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

Quiz 109 - Unruly Unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

Answer 109 - Unruly Unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

Quiz 110 - Sorting Shutout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302


The Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Hint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
CONTENTS

Answer 110 - Sorting Shutout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303


The Answer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
About the Technical Reviewer
Ethan Furman
Ethan, a largely self-taught programmer, discovered Python around the turn of the century but
couldn’t explore it for nearly a decade. When he finally did, he fell in love with its simple syntax,
lack of boilerplate, and ease with which one can express one’s ideas in code. After writing a dbf
library to aid in switching his company’s code over to Python, he authored PEP 409, wrote the
Enum implementation for PEP 435, and authored PEP 461. He was invited to be a core developer
after PEP 435, which he happily accepted.
He thanks his wife for joining him in life’s great adventure, and his daughter for her permission of
the endeavor – without them he would be a much poorer man.
Acknowledgments
I spent a long time in 2021 and 2022 attempting to grow my audience on my website¹ and my Twitter
account². For the Twitter audience, I noticed some other people who would post Python quizzes and
I thought they were fun.
I started doing my own quizzes and they really took off. I would regularly get more than 100,000
views of those quizzes. So I want to thank all my Twitter followers who enjoyed those quizzes and
encouraged me to write this book.
I also want to thank Ethan, my editor, for being willing to read this wacky book and editing for me.
Also thank you to those of you who backed the book on Kickstarter or bought early copies of the
book. I hope you’ll all enjoy the final product.
Mike
¹https://www.blog.pythonlibrary.org/
²https://twitter.com/driscollis
Introduction
Welcome to The Python Quiz Book! Quizzes and puzzles are a great way to review your
understanding of a concept. Quizzes are also a fun and engaging method of learning new topics.
This book aims to have fun and learn about the Python programming language.
The quizzes in this book are not necessarily supposed to guide you in proper programming
techniques, and some examples are anti-patterns that you wouldn’t use in regular code. However,
these code examples are a fun way to introduce different topics, learn how Python works, and see
some quirks in the language.
Each chapter in this book will introduce you to a concept in Python using a quiz. There may be a
hint or two in case you get stuck. The answer to each quiz is in the back of the book.
Many teachers use quizzes as a way to score their students. In this book, you will score yourself.
How well do you know Python? Let’s find out!

Audience
This book is for the curious. If you enjoy doing crosswords, playing word games, or writing code
tests, you will also enjoy doing these Python quizzes.
The quizzes in this book will also help you learn more about the Python programming language and
how it works.

About the Author


Mike Driscoll has been programming with the Python language for over a decade. When Mike
isn’t programming for work, he writes about Python on his blog³ and contributes to Real Python.
As a technical reviewer, he has worked with Packt Publishing and No Starch Press. Mike has also
written several books. Mike is also the founder of Teach Me Python⁴ where you can learn the Python
programming language through his books and courses.
You can see a full listing of Mike’s books on his blog⁵.
Mike frequently posts on Twitter about Python, writing, and other topics. You can follow him at
@driscollis⁶.
³https://www.blog.pythonlibrary.org/
⁴https://www.teachmepython.com/
⁵https://www.blog.pythonlibrary.org/books/
⁶https://twitter.com/driscollis
Introduction 4

Conventions
Most technical books contain certain types of conventions. The primary convention in this book is
code blocks that may or may not have syntax highlighting.
Here is an example:

1 import platform
2
3 def get_operating_system():
4 return platform.platform()
5
6 if __name__ == "__main__":
7 print(f"Your code is running on {get_operating_system()}")

These examples allow you to copy and paste the code directly from the book. However, if you have
any issues with doing that, then you can learn where to download the code examples in the next
section.

Book Source Code


If you ever need to grab a copy of one or more of the Python Quizzes in this book, then all you need
to do is go to the book’s GitHub repository here:

• https://github.com/driscollis/python_quiz_book

Reader Feedback
I welcome feedback about my writing. If you’d like to let me know what you thought of the book,
you can send comments to the following address:

• comments@pythonlibrary.org

Errata
I try my best to avoid publishing errors in my writings, but it happens occasionally. If you happen
to see a mistake in this book, feel free to let me know by emailing me at the following:

• errata@pythonlibrary.org

Now let’s start learning!


Quiz 1 - Exceptionally Crazy
The Python programming language allows you to catch exceptions using the try / except construct.
But what happens if you nest exception handlers and throw in a break statement too?
Your mission in this quiz is to find the answer to that question!

The Quiz
Are you ready to start solving quizzes? Of course, you are!
Here’s your first one:

1 try:
2 for i in range(3):
3 try:
4 1 / 0
5 except ZeroDivisionError:
6 raise ZeroDivisionError("Error: You divided by zero!")
7 finally:
8 print("Finally executed")
9 break
10 except ZeroDivisionError:
11 print("Outer ZeroDivisionError exception caught")

What will be the output if you run this code?

A. Outer ZeroDivisionError exception caught


B. Error: You divided by zero!
C. Error: You divided by zero!
Finally executed
D. Finally executed
E. None of the above

When you are ready, flip to the answer section of this book and check your answer!

Hint
If you’re stuck, try reading about Python’s break statement. Exception handling in Python does not
usually use the break statement.
Answer 1 - Exceptionally Crazy
This is the answer to Quiz 1 - Exceptionally Crazy.
Your original question was:
What will be the output if you run this code?

1 try:
2 for i in range(3):
3 try:
4 1 / 0
5 except ZeroDivisionError:
6 raise ZeroDivisionError("Error: You divided by zero!")
7 finally:
8 print("Finally executed")
9 break
10 except ZeroDivisionError:
11 print("Outer ZeroDivisionError exception caught")

A. Outer ZeroDivisionError exception caught


B. Error: You divided by zero!
C. Error: You divided by zero!
Finally executed
D. Finally executed
E. None of the above

The Answer
D) Finally executed

Explanation
This code causes the ZeroDivisionError to be raised inside the nested exception handler because you
are dividing by zero. Your exception handler catches this, but inside the exception handler, you raise
ZeroDivisionError so that the outer exception handler can run and perhaps handle it differently.
Before you get to the outer exception handler, though, the finally statement must run. The finally
statement ALWAYS runs! Here you print out “Finally executed” and then call break, and break
causes the newly raised ZeroDivisionError to be discarded and the loop to end.
Try running the code through a debugger and see for yourself.
Quiz 2 - Number Explosion
You will sometimes come across examples of code that use one or two asterisks. Depending on how
the asterisks are used, they can mean different things to Python.
Check your understanding of what a single asterisk means in the following quiz!

The Quiz
What will be the output if you run this code?

1 numbers = range(3)
2 output = {*numbers}
3 print(output)

A. {range}
B. (range)
C. [0, 1, 2]
D. (0, 1, 2)
E. {0, 1, 2}

Hint
“Unpacking generalizations” is the term to look up if you get stuck.
Answer 2 - Number Explosion
This is the answer to Quiz 2 - Number Explosion.
Your original question was:
What will be the output if you run this code?

1 numbers = range(3)
2 output = {*numbers}
3 print(output)

A. {range}
B. (range)
C. [0, 1, 2]
D. (0, 1, 2)
E. {0, 1, 2}

The Answer
E) {0, 1, 2}

Explanation
A single asterisk before a Python dictionary or list is known as the unpacking operator. In this
example, you tell Python to unpack three integers (0 - 2) into a set.
Here is the example running in a REPL:

1 >>> numbers = range(3)


2 >>> output = {*numbers}
3 >>> print(output)
4 {0, 1, 2}
5 >>> print(type(output))
6 <class 'set'>

The output of the code shows that you have created a set!
You can also use a single asterisk to unpack a dictionary’s keys:
Answer 2 - Number Explosion 9

1 >>> my_dict = {1: "one", 2: "two", 3: "three"}


2 >>> print({*my_dict})
3 {1, 2, 3}
4 ````
5
6 If you want to take your knowledge of unpacking further, it can help to see Python f\
7 unctions use asterisks:
8
9 ```python
10 >>> def my_func(*args):
11 ... print(args)
12 ...
13 >>> my_func(1)
14 (1,)
15 >>> numbers = range(3)
16 >>> output = {*numbers}
17 >>> my_func(output)
18 ({0, 1, 2},)
19 >>> my_func(*output)
20 (0, 1, 2)

When you see a single asterisk in a function definition, the asterisk means that the function can take
an unlimited number of arguments. In the second example, you pass in the set as a single argument,
while in the last example, you use a single asterisk to unpack the numbers and pass them in as three
separate arguments.
For more information, see PEP 448 – Additional Unpacking Generalizations⁷, which has many more
examples!
⁷https://peps.python.org/pep-0448/
Quiz 3 - Letter Explosion
You learned about exploding a range object in the last quiz. For this quiz, you will extend that
knowledge and discover what happens when you explode a string.
But wait! There’s more here than meets the eye. What is up with the numbers in the squiggly
brackets?
If you’re familiar with string methods, you can figure this quiz out pretty quickly!

The Quiz
What will be output if you run this code?

1 print("{2}, {1}, {0}".format(*"abc"))

A. ‘a, b, c’
B. ‘c, b, a’
C. ’’
D. ‘b, a, c’

Hint
The Python documentation⁸ is your friend this time.
⁸https://docs.python.org/3/library/stdtypes.html
Answer 3 - Letter Explosion
This is the answer to Quiz 3 - Letter Explosion.
Your original question was:
What will be the output if you run this code?

1 print("{2}, {1}, {0}".format(*"abc"))

A. ‘a, b, c’
B. ‘c, b, a’
C. ’’
D. ‘b, a, c’

The Answer
B) ‘c, b, a’

Explanation
Python strings have many methods that you can utilize. In this case, you use the format()⁹ method.
The squiggly numbers are a type of Format String Syntax¹⁰.
In this case, you are telling Python that this string takes three parameters. You are also telling Python
where those parameters should be inserted or interpolated into the string.
The string, "{2}, {1}, {0}", is saying that the third parameter is inserted first; the second parameter
goes in the middle, and the first parameter is inserted last.
To get three parameters passed to this string, you use the single asterisk and unpack a letter-character
string into a function.
You can use that function from the previous quiz here to prove what’s happening:

⁹https://docs.python.org/3/library/stdtypes.html#str.format
¹⁰https://docs.python.org/3/library/string.html#formatstrings
Answer 3 - Letter Explosion 12

1 >>> def my_func(*args):


2 ... print(args)
3 ...
4 >>> my_func(*"abc")
5 ('a', 'b', 'c')

Here you use the single asterisk to pass in three parameters: a, b and c.
Quiz 4 - Type Addition
Python has multiple built-in functions you can use to introspect your code. You’ll learn more about
those functions in a later quiz.
For this quiz, you’ll focus on isinstance(), a function you can use to check if a variable is a particular
type. For example, you might want to check if a variable is a string or an integer.
Good luck!

The Quiz
What will be the output if you run this code?

1 my_list = [True, 1, "python", 5, False, {}, True]


2 integers_found = 0
3 bools_found = 0
4
5 for item in my_list:
6 if isinstance(item, int):
7 integers_found += 1
8 elif isinstance(item, bool):
9 bools_found += 1
10
11 print(f"{integers_found = } {bools_found = }")

A. integers_found = 2 bools_found = 3
B. integers_found = 5 bools_found = 2
C. integers_found = 5 bools_found = 0
D. integers_found = 5 bools_found = 5

Hint
Some types inherit from other types.
Answer 4 - Type Addition
This is the answer to Quiz 4 - Type Addition.
Your original question was:
What will be the output if you run this code?

1 my_list = [True, 1, "python", 5, False, {}, True]


2 integers_found = 0
3 bools_found = 0
4
5 for item in my_list:
6 if isinstance(item, int):
7 integers_found += 1
8 elif isinstance(item, bool):
9 bools_found += 1
10
11 print(f"{integers_found = } {bools_found = }")

A. integers_found = 2 bools_found = 3
B. integers_found = 5 bools_found = 2
C. integers_found = 5 bools_found = 0
D. integers_found = 5 bools_found = 5

The Answer
C) integers_found = 5 bools_found = 0

Explanation
The trick here is that in Python, the Boolean type is a subclass of int, so Booleans are integers. The
other trick is that you check if the item is an int data type BEFORE you check if it is bool, so ALL
the Boolean types get added to the integers_found list.
If you look at my_list, you will see two integers: 1 and 5. There are also three Boolean values: True,
False and True. Two plus three equals five!
Quiz 5 - Positional Arguments
Python functions can take in several different types of arguments. What are the different argument
types called?
If you don’t know, you should review the following:

• Positional arguments
• Keyword arguments

This information may help you solve the quiz, or it may confuse you more. Read the next section
when you’re ready to take a crack at it!

The Quiz
How do you call a function like this? Or can you?

1 def positional(name, age, /, a, b, *, key):


2 print(name, age, a, b, key)

A. positional(‘Mike’, 17, key=’test’)


B. positional(‘Mike’, 17, 2, b=3, key=’test’)
C. positional(‘Mike’, 2, b=3, key=’test’)
D. None of the above

Hint
The code above is valid syntax in Python, starting in Python 3.8. If you get stuck, you might want
to look up PEP 570¹¹, but only do that as a last resort!
¹¹https://peps.python.org/pep-0570/
Answer 5 - Positional Arguments
This is the answer to Quiz 5 - Positional Arguments.
Your original question was:
How do you call a function like this? Or can you?

1 def positional(name, age, /, a, b, *, key):


2 print(name, age, a, b, key)

A. positional(‘Mike’, 17, key=’test’)


B. positional(‘Mike’, 17, 2, b=3, key=’test’)
C. positional(‘Mike’, 2, b=3, key=’test’)
D. None of the above

The Answer
B) positional(‘Mike’, 17, 2, b=3, key=’test’)

Explanation
The first two parameters, name and age are positional only. That means you can’t pass them in as
keyword arguments, which is why you would see a TypeError if you tried to pass either of them in
as keywords. The arguments, a and b can be positional or keyword, whereas key, is keyword-only.
The forward slash, /, indicates to Python that all arguments before the forward slash as positional-
only arguments. Anything following the forward slash is positional or keyword arguments up to
the asterisk. The asterisk indicates that everything following it is keyword-only arguments.
That means that B is the correct way to call this function. There are other ways, of course. But they
aren’t listed here. Experiment with it yourself and see what alternative methods you can come up
with to call this function!
Quiz 6 - Truthy or Falsey
Python supports Booleans in much the same way as other programming languages do. In Python’s
case, it uses the True and False keywords. But there is also the concept of truthy and falsey. An
example of a truthy value in Python is a number greater than zero (also a number less than zero),
and an example of a falsey value would be an empty string. When used in a conditional expression
or some functions, these values return True or False.
Why does this matter? Because you’ll write code where you need to know if a string is empty or not.
You could check if a dictionary is empty or not too.
With that in mind, you are ready to try this chapter’s quiz!

The Quiz
What does the following code print out, if anything?

1 print(sum([
2 all([[]]),
3 all([]),
4 all([[[]]])
5 ]))

A. An exception
B. 1
C. 2
D. 3
E. None of the above

Hint
Did you know that a bool type in Python is a subclass of int?
Answer 6 - Truthy or Falsey
This is the answer to Quiz 6 - Truthy or Falsey.
Your original question was:
What does the following code print out, if anything?

1 print(sum([
2 all([[]]),
3 all([]),
4 all([[[]]])
5 ]))

A. An exception
B. 1
C. 2
D. 3
E. None of the above

The Answer
C) 2

Explanation
Python includes many different built-in functions¹². You can see two of these functions in this quiz:

• sum() - takes an iterable, sums up the contents (if it can), and returns the total
• all() - takes an iterable and returns True if all the elements in the iterable are true and False
otherwise.

Try running each of those all() functions that are inside the sum() function individually:

¹²https://docs.python.org/3/library/functions.html
Answer 6 - Truthy or Falsey 19

1 >>> all([[]])
2 False
3 >>> all([])
4 True
5 >>> all([[[]]])
6 True

What’s going on here? To figure that out, you will look at each of these statements one at a time:

• all([[]]) returns False because the passed in list has one element, an empty list []. An empty
list is falsey!
• all([]) returns True because the iterable is empty. If you passed it an empty string, it would
also return True!
• all([[[]]]) returns True because the passed single nested list contains something. In this case,
it contains an empty list. But because it contains something, it now evaluates to True.

In Python, the bool data type is a subclass of int. That means that True maps to one and False maps
to 0.
Look at that code again:

1 print(sum([
2 all([[]]),
3 all([]),
4 all([[[]]])
5 ]))

You can rewrite this code to use the return values you saw earlier:

1 print(sum([
2 False,
3 True,
4 True
5 ]))

Then you can rewrite it again even simpler:


Answer 6 - Truthy or Falsey 20

1 print(sum([
2 0,
3 1,
4 1
5 ]))

What does 0 + 1 + 1 evaluate to? The number 2, of course!


Quiz 7 - List Popping
The Python list data type is much like an array in other programming languages. The list has many
different methods associated with it. You can get a full listing of those methods like this:

1 my_list = []
2 print(dir(my_list))

One of those methods is called pop(). You can pass in an index of the item you want to pop out of
the list (if you don’t, the last item is chosen). What that means is that you are removing an item
from the list.
But what happens if you iterate over the list and attempt to remove some items? If you know the
answer to that, this quiz will be easy!

The Quiz
What does the my_list look like after this code runs?

1 my_list = list(range(1, 7))


2 for index, item in enumerate(my_list): my_list.pop(index)
3 print(my_list)

A. []
B. [1, 3, 5]
C. [2, 4, 6]
D. An IndexError is raised

Hint
What does enumerate() do?
Answer 7 - List Popping
This is the answer to Quiz 7 - List Popping.
Your original question was:
What does the my_list look like after this code runs?

1 my_list = list(range(1, 7))


2 for index, item in enumerate(my_list): my_list.pop(index)
3 print(my_list)

A. []
B. [1, 3, 5]
C. [2, 4, 6]
D. An IndexError is raised

The Answer
C) [2, 4, 6]

Explanation
This code runs because you are calling enumerate(). The enumerate()¹³ function will return an
enumerate object. That means you are no longer iterating over the list; you are iterating over the
enumerate object itself!

When you iterate over an enumerate object, you get an index and an item returned. These variables
allow you to work with the list without worrying about causing problems.
Try running this code that doesn’t use enumerate():

¹³https://docs.python.org/3/library/functions.html#enumerate
Another random document with
no related content on Scribd:
in good condition for their government owner—His “discovery”
that the states, political entities, made the Constitution of
America, the nation of men—Story of America (from May 29,
1787, to July, 1917) being a sealed book to him, he does not
know that our Constitution is both federal and national—
Supreme Court, in early days and in 1907, and Webster and
Lincoln tell him his mistake—Not knowing the decision of
Gettysburg, recorded at Appomattox, he chooses between Lord
North of 1775 and Calhoun and summons the latter to prove that
the American people did not make their Constitution and its
grant of enumerated power to interfere with their individual
freedom—Jefferson, Pendleton, Webster and many other
Americans correct Sheppard’s error of fact—As the American
people of 1776 accomplished their successful Revolution
against government, may it not be the thought of Sheppard and
other Tories that the Eighteenth Amendment has been
established by a successful revolution of government against
the people—Marshall again tells us of the American day when
the legal necessity “was felt and acknowledged by all,” that
every power to interfere with human liberty must be derived from
the people in their “conventions”—Acting on the Congress
proposal of 1917, governments of state citizens command the
American citizen and create a new government power to
interfere with his individual liberty—But no statesman has yet
told us how or when, prior to 1917, we became “subjects.”
XIX. Are We Citizens? Page 298
Hamilton thinks it a prodigy that Americans, in “conventions,”
voluntarily constitute the enumerated First Article government
powers to interfere with their individual liberty—Marshall, in
Supreme Court, declares “conventions” to be the only manner in
which they can act “safely, wisely and effectively” in constituting
government of themselves, by making such grants—When
proposed 1917 first new grant of that kind is supposedly made,
American people and their “conventions” are completely ignored
—The proposers have a Fifth Article which does not mention
“conventions”—The proposers have the old Tory concept, that
the people are the assets of the state and that government is the
state—Still trying to find out how and when we became
“subjects,” we expect to get information from the litigations of
1920—We expect great counsel, on one side, to urge the facts
we know—We fear that other great counsel will urge, in reply,
some fact or facts which we have not been able to ascertain—
We are certain that there is no Eighteenth Amendment, if the
facts we have learned are all the facts—That we may listen
intelligently to all the great counsel, we review some of the facts
we have learned.
XX. Lest We Forget Page 307
“The important distinction so well understood in America,
between a constitution established by the people and
unalterable by the government and a law established by the
government and alterable by the government”—Our first glance
at briefs of 1920 gives us hope that some modern leaders have
acquired the knowledge of Hamilton and his generation—We
find, in one brief, in Marshall’s words, the Supreme Court
statement of the fact that “conventions” of the people, not states
or their governments, made the Constitution with its First Article
grants of power to interfere with human liberty—But this brief, to
our amazement, is that of the foremost champion of the only
other grant of that kind, the Eighteenth Amendment, a grant
made entirely by government to government—In 1920, seven
litigations argued and reported under the one title “The National
Prohibition Cases”—Distinguished counsel appear for many
clients, for the claimed omnipotent Parliament of America, for
the American government which we used to know as our
supreme government, for a few state governments who did not
wish to be part of the omnipotent Parliament, for those engaged
in the lawful business of manufacturing, etc., the commodities
named in the Eighteenth Amendment—Like the human right to
breathe, such manufacture, etc., was not the privilege of a
citizen—Both rights are among the human rights men have
before they create nations and give governments power to
interfere with some or all of their human rights—Citizens of
America, giving their only American government its enumerated
powers, gave it no power to interfere with the human right
mentioned in the new Amendment—Human rights never are
privileges of citizens—Citizens establish government to protect
existing human rights—Only “subjects” get any rights or
privileges from government—All early Americans knew these
primal truths—Neither the French aristocrats, before French
Revolution, nor Tories of 1776 in England or America knew them
—Eighteenth Amendment Tories do not know them—Madison
(in 1789) and Supreme Court (in 1890) knew that commodities
named in new Amendment are among those in which a human
right “of traffic exists”—In litigations of 1920, no counsel appear
on behalf of the human rights of American citizens—But we
know that no decision of our own Supreme Court, established to
secure our human rights, although the decision may settle
disputes between other litigants, can change us from “citizens”
into “subjects.”
XXI. Briefs Ignore the American Page 325
Citizen
No counsel knows all are discussing whether Americans, twelve
years after 1776, voluntarily became “subjects”—Common
concept of all that Fifth Article a “grant” of power to state
governments (of state citizens) making them attorneys-in-fact for
citizens of America—Discussion entirely as to extent of power
“granted”—Eighteenth Amendment concept that Fifth Article
“grant” made some governments of state citizens a supreme
American Parliament, unrestrained master of every human right
of all American citizens—Opposing concept that the Fifth Article
“grant” made those state governments a Parliament whose one
limit is that it cannot interfere with the sovereignty of any political
entity which is a state—Both concepts ignore supremacy of
nation of men over federation of states—Both ignore dual nature
of “one national and federal Constitution”—Both ignore
“conventions” in Seventh and Fifth Articles as the citizens of the
American nation—Both ignore that each state “legislature” is
attorney-in-fact for the citizens of its own state and that no
legislatures are (except Congress in enumerated matters)
attorneys-in-fact for the citizens of America in any matter—Our
facts, brought from our education with the early Americans, all
ignored by all counsel in the litigations—The Virginia Convention
itself and Lee, Pinckney, Hamilton, Madison, Wilson, Iredell and
others state what all counsel of 1920 entirely ignore.
XXII. No Challenge to the Tory Page 335
Concept
Eighteenth Amendment rests on imaginary Fifth Article “grant”
making the state governments of state citizens attorneys-in-fact
for the citizens of America, empowered to give away all human
rights of the citizens of America—“Grant” assumed in every brief
—No brief recognizes that one supposed “grantee” is supposed
“grantor”—Or that each of two supposed “grantees” was a
competent maker of Articles (as proposed Articles were
respectively federal or national) before and when the
“conventions” made the Fifth Article—Or that Philadelphia
Convention knew and held “conventions” existing ability
competent to make any Article and state legislatures, existing
ability incompetent ever to make Articles like First Article or
Eighteenth Amendment—Or that Tenth Amendment declares no
power given to state “legislatures,” while all ability to make
national Articles “reserved” to “conventions” of “the people” of
America—No brief challenges sheer assumption of Fifth Article
“grant” or supports assumption by any fact—Every brief, for or
against Amendment, is based on the sheer assumption—No
brief knows that enumerated powers of only American
government to interfere with human freedom can be changed by
no one save the citizens of America themselves in their
“conventions”—Madison’s tribute to these “conventions” in which
“free inhabitants” constitute new government power over
themselves—Hamilton explains great danger to human liberty if
“legislatures” or permanent government bodies could create
such new government power—That knowledge of his generation
confirmed by story of government-made supposed Eighteenth
Amendment—Our gratitude to that generation of men who
(1776) made it and (1788) left it impossible that governments
could create new government power to interfere with American
human liberty—Our regret that modern leaders have not known
this great and immutable protection to American liberty.
XXIII. The Challenges That Failed Page 350
Supreme Court wisely writes no opinion in “National Prohibition
Cases”—In each of four numbered paragraphs, Court states its
own negation of one challenge made to new Amendment—All
four challenges are negatived in seventeen lines of statement—
First two challenges trifling and purely technical—Third
challenge based on rights of the citizens of some particular state
—Fourth challenge to “extent” of Fifth Article “grant” of power by
“conventions” to “conventions” and “legislatures”—This
challenge asserts “grant” which advocates of Eighteenth
Amendment must and cannot prove—Court negative amazingly
accurate—All counsel have argued incessantly about “extent” of
power “granted” by Fifth Article—Court negatives in statement
which speaks of power “reserved” in Fifth Article—Concept of
“grant” disappears—Court knows what “conventions” knew,
when they made Fifth Article, when they insisted on Tenth
Amendment Declaration expressly stating the distinct reservees
of the two existing powers “reserved” in Fifth Article—Supreme
Court of Marshall’s day knows it and Supreme Court of 1907
knows it—“Citizen or Subject?”—Eighteenth Amendment
answers “Subject”—Real Constitution answers
“Citizen”—“Conventions” insisted on plain statement of correct
answer—Counsel of 1920 do not know it—Their four challenges
make plain that fact—All challenges based on error that
governments of state citizens are attorneys-in-fact for citizens of
America—In Virginia Convention and in Supreme Court,
Marshall explains that powers of state governments “proceed
not from the people of America” but from the citizens of each
respective state—No counsel of 1920 knows this important fact.
XXIV. Governments Claim Americans as Page 371
Subjects
Patrick Henry, opposing Constitution in the “conventions,” knows
that it takes power from the state legislatures and gives them no
power—All modern leaders “know” that it gives those
legislatures great power as attorneys-in-fact for the citizens of
America—Many modern leaders “know” that it makes those
legislatures an omnipotent Parliament over the citizens of
America—No modern leaders remember 1781 and 1787
existing ability of the state legislatures to make federal Articles
or Articles not creating government power to interfere with
human liberty—Common modern concept that Fifth Article is
“grant” to these “legislatures” and to the very “conventions”
which made the Fifth Article—Leading brief, against
Amendment, more than fifty times admits or asserts this
imaginary and remarkable “grant”—Some extraordinary
concepts of our American institutions in briefs—In a famous
opinion, Marshall explains a fact and on it bases the entire
decision of the Supreme Court—The fact itself is that the
Constitution granted no power of any kind to the state
legislatures—No brief knows or urges this fact or any of the facts
we learned in the “conventions,” the facts on which we base our
challenge to the Eighteenth Amendment concept that we are
“subjects”—Briefs for the Amendment examined to find out why
we are supposed to be “subjects”—Amazing claim that, when
governments alone change the national part of the Constitution,
Supreme Court has no power even to consider whether
governments in America can make a change in the enumerated
powers given to their own government by the citizens of America
—Remarkable Tory concept that the number of Senators from
each state is the only thing in America immune from government
invasion, if enough governments combine—Indignation of
American citizen changes to mirth when he realizes this concept
to be only basis of thought that he is a “subject” or that there is
an Eighteenth Amendment—American citizen, seeking to find (in
the briefs for the Amendment) what happened, between 1907
and 1917, to make him a “subject,” startled to hear the answer,
“Nothing”—Citizen’s amusement increased on learning, in same
briefs, that whole American people, in Constitution which
expressly declares it gives no power to state governments,
made those governments of state citizens irrevocable and
omnipotent attorneys-in-fact for the citizens of America—
Amusement increased by finding that main champion of Tory
concept quotes Marshall’s Supreme Court story of the making of
the Constitution, but omits, from the quotation, the paragraph in
which Marshall points out that everyone knew why the
“legislatures” could not make and only the “conventions” could
make the national First Article, with its grant of enumerated
power to interfere with human liberty—Curiosity added to mirth
on finding this brief echo Madison’s own knowledge that his Fifth
Article contains nothing but “procedural provisions,” while brief
bases its entire contention on mere assertion that Fifth Article is
greatest grant of power ever made by free men to government.
XXV. Citizen or “Eighteenth Page 397
Amendment”?
Congress is only legislature with any power of attorney from the
citizens of America—At very beginning and very end of original
Constitution, citizens of America expressly so state—All briefs of
1920 based on asserted assumption denying those two
statements and insisting Fifth Article is “grant” to governments of
state citizens—Briefs for new Amendment assert “grant” made
governments of state citizens omnipotent master of everything in
America (including all human rights) save number of Senators
from each state—On this Tory concept depends entirely
existence of Eighteenth Amendment—Tory concept being
absolute myth, Amendment disappears—Amusing to find Tory
briefs for Amendment with American citations and quotations
which annihilate Tory concept—Unconscious humor of Wheeler
surpasses “Comic Blackstone”—Tory legions, fighting under
crescent of Mohammet, claim to be American and Christian
crusaders—Americans would have remained “subjects” if
Parliament, passing the Stamp Act, had said: “You subjects
must obey this command we make but, making it, we do not
legislate”—“Statement” that citizens of America universally
demanded this sole Amendment which attempts to change the
First Article enumerated powers—“Proof” that 4742 Tory
members of governments of state citizens said “Yes” to the
change—Jefferson and Madison tell us that concentration of all
power in legislatures “is precisely the definition of despotic
government,” that 173 “despots would surely be as oppressive
as one,” and that “an elective despotism was not the
government we fought for”—Calhoun contended one state might
defy supreme will of citizens of America—Tories for Amendment
go far beyond doctrine finally repudiated by Gettysburg—On
Tory concept that we are “subjects” of omnipotent government,
assert that some governments of state citizens may dictate, in
all matters of human right, what the citizens of America may and
may not do—Echo from “conventions” which made Fifth Article,
“How comes it, sir, that these state governments dictate to their
superiors, to the majesty of the people?”
XXVI. The American Citizen Will Remain Page 416
Supreme Court holds American people, “for most important
purposes,” chose to be one nation, with only one government of
the First Article enumerated powers to interfere with human
liberty—America, the nation of men, and United States, the
subordinate federation of states—Tories for new Amendment
must prove that American people, as one “important” purpose,
meant that governments of state citizens could interfere with
every human right of American citizens—Reserved rights and
powers of American citizens are entirely at their own direct
disposal, for exercise or grant, “despite their legislatures,
whether representing the states or the federal government”—
American citizen must know this of his own knowledge or his
human freedom will disappear—Emmett and Webster and their
generation knew it—Madison writes Fifth Article and states
exactly what it is to the “conventions” which made it—Hughes
unable to begin his Tory argument for new Amendment without
adding to that Madison statement what Madison pointedly did
not say—Senate now about to repeat 1917 blunder that
governments of state citizens have aught to do with altering the
national part of the American Constitution, which part is within
the exclusive control of the citizens of America themselves
—“Conventions” are the people—“Legislatures” are
governments—“Citizen or Subject?”—Supreme Court answer
certain—Court’s history and traditions show American concept
of Hamilton that this Court bulwark of American citizen against
government usurpation of power to interfere with human liberty
—Webster forecast Court decision on new and Tory
Amendment, answering “Citizen or Subject?”—All Americans
once knew same correct answer to same question by Pendleton
in Virginia Convention of 1788, “Who but the people can
delegate power? What have the state governments to do with
it?”
APPENDICES
I. The Original Constitution of the Page 445
United States
II. The Resolution Which Proposed Page 458
the Constitution to the
Conventions of the People of
America
III. The First Seventeen Amendments Page 460
to the Constitution
IV. The Alleged Eighteenth Page 465
Amendment
V. The Nineteenth Amendment Page 466
CITIZEN OR SUBJECT?
CHAPTER I
SUBJECTS BECOME CITIZENS

The average American of this generation does not understand


what it means to be a citizen of America. He does not know the
relation of such a citizen to all governments in America. He does not
know the relations of those governments to one another. If this
ignorance should continue, the citizen of America would disappear.
The American would become again a subject, as he was when the
year 1776 opened.
The supposed Eighteenth Amendment is not in the Constitution
unless the American already is a subject.
It is vital to every individual interest of the average American that
he should know these things which he does not know. Happily for
him, his ignorance is not as that of the public leaders of his
generation. Their concept of the American and his relation to
governments in America is one which contradicts the most definitely
settled and clearly stated American law. On the other hand, the
average American merely has a mind which is a blank page in these
matters. As a result, it is the greatest danger to his individual interest
that their concept largely guides his attitude in public affairs of the
utmost moment to him.
The Americans of an earlier generation, who created the American
nation of men and all governments in America, accurately knew the
status of the American citizen and his relation to all governments.
Their accurate knowledge was an insistent thing which guided their
every act as a people in the period between 1775 and 1790, in which
latter year the last of the Americans became citizens of America.
Their knowledge came to them from their own personal experience
in those fifteen years. They were a people, born subjects of
government, who died citizens of a great nation and whose every
government, in America, was their servant. This great miracle they
themselves had wrought in the fifteen years between 1775 and
1790. Their greatest achievement, as the discerning mind has
always realized, is what they did in the last four of those momentous
years. They brought to its doing their valuable experience and
training of the previous eleven years. That is why they succeeded,
so far as human effort can secure human liberty by means of written
constitutions of government, in securing to themselves and their
posterity the utmost measure of protected enjoyment of human life
and happiness. That we, their posterity, may keep their legacy intact
and transmit it to the generations to come, it is necessary that we,
the average Americans, should share somewhat with them their
amazingly accurate knowledge of the simple but vital facts which
enabled them to create a nation and, by its American Constitution, to
secure to themselves, its citizens, protected enjoyment of life, liberty
and happiness.
When they were actually engaged in this work of creation, it was
truthfully said of them that “The American people are better
acquainted with the science of government than any other people in
the world.” For over a hundred years the history of America attested
the truth of that statement. As they were a simple people, their
knowledge of the science of government was derived from their
accurate understanding of a few simple facts. It is a certainty that we
can keep their legacy by learning those same facts. Let us quickly
learn them. The accurate knowledge of them may best be acquired
by briefly living again, with those simple Americans of an earlier
generation, through their days from 1775 to 1790.
The individual Americans of that generation were all born subjects
of the British government. We do not understand the meaning of that
statement until we accurately grasp the vital distinction between a
“subject” of a government and a “citizen” of a nation.
It is hardly necessary to point out, but it is amazingly important to
remember, that a “subject,” as well as a “citizen,” is first of all a
human being, created by an omnipotent Creator and endowed with
human rights. All would be well with the world, if each human being
always accurately knew the difference between right and wrong and
if his accurate knowledge invariably controlled his exercise of his
human freedom of will. In that case, no human government would be
needed to prescribe and to enforce rules of personal conduct for the
individual. As such is not the case, human government must exist.
Its sole reason for existence, therefore, is that it may prescribe and
enforce rules for those whom it can compel to obey its commands
and that it may thus secure the utmost measure of protected
enjoyment of human rights for those human beings whose
government it is.
Time does not permit and necessity does not require that we dwell
upon the various types of government which have existed or which
have been created supposedly to meet this human need. It is
sufficient to grasp the simple and important fact that government
ability to say what men may or may not do, in any matter which is
exercise of human freedom, is the very essence of government.
Where a government has no ability of that kind, except what the men
of its nation grant to it, where those men limit and determine the
extent of that ability in their government, the men themselves are
citizens. Where a government claims or exercises any ability of that
kind, and has not received the grant of it directly from the men of the
nation, where a government claims or exercises any ability of that
kind, without any grant of it, or by grant from government to
government, the men of that nation are subjects.
In the year 1775, under the British law, the Parliament at
Westminster claimed the unqualified right to determine in what
matters and to what extent laws should be made which would
interfere with individual freedom. From such decision of the
legislative part of the British Government there was no appeal save
by force or revolution. For this reason, that every human being under
that Government must submit to any interference with individual
freedom commanded by that Legislature, all British human beings
were “subjects.” And, as all Americans were then under that British
Government, all Americans were then “subjects.” Such was their
legal status under the so-called British Constitution. Curiously
enough, however, until a comparatively short time prior to 1775, such
had not been the actual status of the Americans. In this sharp
contrast between their legal and their actual status, there will be
found both the cause of their Revolution and the source of their great
and accurate knowledge of the sound principles of republican
government which they later made the fundamental law of America.
From the day their ancestors had first been British colonists in
America their legal status had been that of subjects of the British
Government. But, so long as they remained merely a few widely
scattered sets of human beings in a new world, struggling to get a
bare existence from day to day, they offered no temptation to the
omnipotent British Government to oppress them, its subjects. They
still had to show the signs of acquiring that community wealth which
has always been the temptation of government to unjust exaction
from the human beings it governs. For that reason, their legal
government concerned itself very little about them or their welfare. It
thus became their necessity to govern themselves for all the
purposes for which they locally needed government as security to
their individual welfare.
Only thirteen years after the first permanent English settlement in
Virginia, “Sir George Yeardley, then the Governor of the colony, in
1619 called a general assembly, composed of representatives from
the various plantations in the colony, and permitted them to assume
and exercise the high functions of legislation. Thus was formed and
established the first representative legislature that ever sat in
America. And this example of a domestic parliament, to regulate all
the internal concerns of the country, was never lost sight of, but was
ever afterwards cherished [until 1917] throughout America, as the
dearest birthright of freemen.” (1 Ell. Deb. 22.)
“On the 11th of November, 1620, those humble but fearless
adventurers, the Plymouth colonists, before their landing, drew up
and signed an original compact, in which, after acknowledging
themselves subjects of the crown of England, they proceed to
declare: ‘Having undertaken, for the glory of God, and the
advancement of the Christian faith, and the honor of our king and
country, a voyage to plant the first colony in the northern parts of
Virginia, we do, by these presents, solemnly and mutually, in the
presence of God and of one another, covenant and combine
ourselves together into a civil body politic, for our better ordering and
preservation, and furtherance of the ends aforesaid. And by virtue
hereof do enact, constitute, and frame, such just and equal laws,
ordinances, acts, constitutions, and officers, from time to time, as
shall be thought most meet and convenient for the general good of
the colony; unto which we promise all due submission and
obedience.’ This is the whole of the compact, and it was signed by
forty-one persons.
“It is, in its very essence, a pure democracy; and, in pursuance of
it, the colonists proceeded soon afterwards to organize the colonial
government, under the name of the Colony of New Plymouth, to
appoint a Governor and other officers and to enact laws. The
Governor was chosen annually by the freemen, and had at first one
assistant to aid him in the discharge of his trust. Four others were
soon afterwards added, and finally the number was increased to
seven. The supreme legislative power resided in, and was exercised
by, the whole body of the male inhabitants, every freeman, who was
a member of the church, being admitted to vote in all public affairs.
The number of settlements having increased, and being at a
considerable distance from each other, a house of representatives
was established in 1639, the members of which, as well as all other
officers, were annually chosen.” (1 Ell. Deb. 25.)
These are two examples typical of the way in which the English
colonists, for the first hundred years, largely governed themselves by
legislators chosen from among themselves. In this manner, while
legally “subjects” of their European government, these Americans
were actually “citizens” of their respective communities, actually
governed in their individual lives and liberties by governments which
derived all their powers of government from these “citizens.” In this
manner, through the best teacher in the world, personal experience,
they learned the vital difference between the relation of “subject” and
“citizen” to governments. Later, the echo of that education was heard
from Lincoln when he pleaded that government of the people, by the
people and for them should not perish from the earth.
As early as 1754 these Americans began to feel the first real
burden of their legal status as “subjects.” Their community wealth
was beginning to attract the attention of the world. As a result, the
legal Government awoke to the fact of their existence and of its own
omnipotent ability to levy upon that wealth. The Americans, for more
than a century educated in actual self-government, quickly showed
the result of that education to the accurate knowledge that no
government can have any just power except by the consent or grant
of those to be governed by the exercise of such power. As far back
as 1754, deputies of the various American colonies, where human
beings had educated themselves to be free men, assembled at
Albany in an endeavor to propose some compromise by which the
American people would be enabled to preserve their human freedom
against unjust interference by the Westminster Legislature. We are
all familiar with the failure of that endeavor. We are all familiar with
the successive steps of the continuing struggle between “subjects,”
educated to be “citizens,” and an omnipotent government, unshaken
in its purpose to make their actual status the same as their legal one.
When the year 1776 dawned, these Americans were still
“subjects” under the law of the British Empire. They were, however,
“subjects” in open rebellion against their government, justifying their
rebellion on the basic American legal principle that every just power,
even of a lawful government, must be derived from the consent or
grant of the human beings themselves who are to be governed. On
the memorable day in July of that year, despairing of any success in
getting the British Government to recognize that basic principle, and
asserting, for the first time in history, that they themselves were
collectively the possessors of the supreme human will in and for
America, they enacted the immortal Statute which we know as the
Declaration of Independence.
The Declaration of Independence, which was the first
political act of the American people in their independent
sovereign capacity, lays the foundation of our national
existence upon this broad proposition: “That all men are
created equal; that they are endowed by their Creator with
certain inalienable rights; that among these are life, liberty,
and the pursuit of happiness.” (Justice Bradley’s opinion in
Slaughter House Cases, 16 Wall. 36, at page 115.)
In this Statute, the American people clearly stated and definitely
settled for all time the basic legal principle on which rests the validity
of every constitutional article or statute law, which either directly
interferes or vests ability in governments to interfere with an
American in the exercise of his human freedom. There is nothing
vague or ambiguous in their statement. The legal principle, so clearly
stated and so definitely settled, is that no government in America can
have any just power of direct interference with individual freedom
unless such power be derived by direct grant from the Americans to
be governed by the exercise of that power.
That Statute has never been repealed. The Americans of that
generation, throughout all the momentous political battles of the next
thirteen years, when they were making and unmaking nations and
creating a federation of nations, and later subordinating it to a union
of human beings, never failed to obey that Statute and to act in strict
conformity to its basic American principle.
From the moment when that Statute was enacted by the supreme
will in America, every American ceased forever to be a “subject” of
any government or governments in the world. It was not until 1917
that any government or governments dared to act as if the American
were still a “subject.”
In that summer of 1776, as the Americans were engaged with their
former Government in a bitter and protracted war, they had little time
or thought to give, as one people, to the constitution of a government
best designed to secure to themselves the utmost possible measure
of protected enjoyment of individual human freedom. In their
rebellion, they had delegated the management of their common
interests to a committee of deputies from each former colony, which
committee was called the Congress. By the declared supreme will of
the whole American people, the Americans in each former colony
now constituted an independent nation, whose human members
were now the “citizens” of that nation. Under the declared basic
American legal principle, it was imperative that any government
should get its every valid power from its own citizens. Knowing this,
the Congress, almost immediately after the Declaration of July, made
the formal suggestion to the citizens in each nation that they
constitute a government for themselves and that they grant to such
government ability to interfere with their own human freedom in such
matters and to such extent as they deemed wise. The manner in
which the citizens of each nation acted upon this suggestion should
have stamped itself so irrevocably upon the mind of America as
never to have been forgotten by any later generation of Americans.
The citizens of those nations were of the “people who were better
acquainted with the science of government than any other people in
the world.” In each nation they were creating the very essence of
security for a free people, namely, a government with limited ability
to interfere with individual freedom, in some matters, so as to secure
the greatest possible protected enjoyment of human liberty. They
knew, as only human beings could know who were then offering their
very lives to uphold the basic law of America, that such ability could
never be validly given to any government by government itself,
acting in any manner, but only by direct action and grant of those
later to be governed by the exercise of that ability. What method did
those citizens, so thoroughly educated in the basic principles of
republican government, employ to secure the direct action of the
human beings themselves in giving that ability of that kind to their
respective governments? They acted upon the suggestion from the
Congress of 1776, as Marshall later expressed it from the Bench of
the Supreme Court, “in the only manner in which they can act safely,
effectively and wisely on such a subject, by assembling in
convention” in their respective states. Long before Marshall voiced
judicial approval of this American method of direct action by the
people themselves, in matters in which only the people themselves
can validly act at all, Madison, in the famous Virginia convention of
1788, paid his tribute to these conventions of the people in each of
the thirteen nations. This was the tribute of Madison: “Mr. Chairman,
nothing has excited more admiration in the world than the manner in
which free governments have been established in America; for it was
the first instance, from the creation of the world to the American
Revolution, that free inhabitants have been seen deliberating on a
form of government, and selecting such of their citizens as
possessed their confidence, to determine upon and give effect to it.”
(3 Ell. Deb. 616.)
Later herein there will be occasion to speak at greater length of
this American method of direct action by the people themselves,
through the deliberative conventions of deputies chosen by the
people and from the people for that one purpose, giving to
governments a limited ability to interfere with individual freedom. At
this point, it is sufficient to say that, since 1789 and until 1917, no
government in America ever claimed to have acquired ability of that
kind except through the action of such a convention or conventions
or through the direct voting of its citizens themselves for or against
the grant of such ability.
If we again turn our minds upon those later days of 1776, we find
that the Americans, through the direct action of the people in each
independent nation, had become respectively citizens of what we
now know as their respective states, each of which was then a free
nation. Those thirteen nations were then allied in war. There did not
yet exist even that political entity, later created and known as a
federation of those nations. At that time and until quite some years
after the Revolution had ended, there was no such thing as a
“citizen” of America, because the America we know, the organized
human membership society which is the American nation, did not yet
exist. At that time and until the American nation did actually exist, as
a political entity, there was no government in the world and no
collection of governments in the world, which, on any subject or to
any extent, could interfere generally with the individual freedom of
Americans, as Americans. In each of the thirteen American nations,
the citizens of that nation had vested their own government with
some ability of that kind.
At this point, it is well to digress for a moment in order that we may
well understand that in none of these thirteen nations did its citizens
vest in its government an unlimited ability to interfere with individual
freedom. All the citizens of those respective nations were then
battling with a mighty Government which claimed such unlimited
ability over all of them, as subjects, and they were battling to
establish forever in America the basic doctrine that no government of
free men could ever have unlimited ability of that kind. In each of the
thirteen nations, its citizens vested its government with ability of that
kind only to a limited extent. They did this in strict conformity to
republican principles.
For the many who do not know, it is well to state clearly the
distinction between a pure democracy and a republic. In both, the
human beings constitute the nation or the state and are its citizens.
In both, the citizens themselves limit the matters and the extent in
which they shall be governed at all in restraint of their individual
freedom. In both, therefore, it is accurate and truthful to state that the
people govern themselves. The actual difference lies in one fact. In a
democracy the people themselves assemble and themselves enact
each specific rule of conduct or law interfering with individual
freedom. In a republic, it is always possible that the citizens may
assemble, as in a pure democracy, and enact any specific rule of
conduct or law. But, in a republic, its citizens generally prefer to act,
in such matters, through attorneys in fact or representatives, chosen
by themselves for the special purpose of exercising a wise discretion
in making such laws. In a true republic, however, where the citizens
are to remain free men, they secure to themselves absolute control
of their representative lawmakers through two most effective means.
In the first place, they ordain that their attorneys in fact for the
purpose of law-making, generally called their legislators, shall be
selected by themselves from time to time, at comparatively short
intervals. This precaution enables the people, through new attorneys
in fact, quickly to repeal a law of which they do not approve. In the
second place, the people, in constituting their government, limit the
law-making ability of these temporary attorneys in fact or legislators.
This is the most important fact in a free republic. Later herein there
will be explained the marvelous and effective manner in which this
particular security for human freedom was later achieved by the
citizens of the Republic which we know as America, when they
constituted their government. At present, there is to be mentioned
the general method which the citizens of each of those thirteen
nations, in 1776, employed to achieve this particular security.
In each nation the citizens constituted a legislature to be their only
attorney in fact for the purpose of making valid laws. In this
legislative department they did not vest enumerated powers to

You might also like