Value census and type labels
Independent Mastery Check (no AI assistance).
Prerequisites
Day 03 recovery drill; Python can be launched from the terminal; review the prediction/observation method.
Learning Objective
Use repr(), type(), and bool() to tell apart values that look alike on screen (0, "0", "", None), and explain why the text "0" is not the number 0.
Instructions
Study source: within this activity's existing reading/practice time, use Automate the Boring Stuff with Python, 3rd edition, Chapter 1; Practice Questions; Appendix B answers, then explain one connection to the local task in your own words. Keep the local exercise and acceptance checks; use its original explanation if the external source is unavailable. Required work: Save the following as census.py. Before running it, write a prediction for each output line. Then run python3 census.py, capture the exact output, and compare it with your prediction.
for value in [0, "0", "", None]:
print(repr(value), type(value).__name__, bool(value))
print("0" == 0, int("0") == 0)
Explain in one or two sentences why "0" (text) and 0 (integer) print differently with repr(), have different types, and have different truth values.
Optional work: only after the required evidence is complete, add one more value of your choice (for example 0.0 or "False") to the list, predict its row, and run again.
Practice & Prediction Log
Predict all five output lines of this program before running it, then record the exact output:
for value in [0, "0", "", None]:
print(repr(value), type(value).__name__, bool(value))
print("0" == 0, int("0") == 0)
Finally, explain why the text "0" is not numeric zero.
print() hides quotes; repr() shows them. A non-empty string is truthy even if its only character is 0, and a string never equals an int.
Exact output:
0 int False
'0' str True
'' str False
None NoneType False
False True
Explanation: repr() shows quotes around strings, so "0" prints as '0' while the integer prints as 0. type(...).__name__ is int for 0, str for "0" and "", and NoneType for None. bool() is False for numeric zero, the empty string, and None, but True for "0" because it is a non-empty string. The last line shows "0" == 0 is False (a str never equals an int); int("0") converts the text to the number 0, so that comparison is True.
Objective Knowledge Check & Diagnostic Trace
Answer the following questions to verify your understanding. Select your declared assistance condition before submitting.
What does print(repr("0"), type("0").__name__, bool("0")) print?
"0" is a one-character string: repr() shows it as '0', its type is str, and any non-empty string is truthy, so the line is '0' str True.
repr() keeps the quotes of a string, and only the empty string is falsy among strings.
Attempt History & Evidence
Your prediction log and observed output contain all five exact lines above, and your explanation names the type difference (str vs int), the truthiness rule (non-empty string is True), and the need for an explicit conversion with int(). The log states the required/optional boundary and that no AI assistance was used.
Authoritative Source Resources & Provenance
Automate the Boring Stuff with Python, 3rd edition
Relevant Section / Range: Chapter 1; Practice Questions; Appendix B answers
Verified Version & Date: Public edition checked 2026-11-01; moving pages may change
Beginner teaching and answer-keyed practice before checking exact semantics in the Python reference; selected chapters only, not the book's entire automation stack.
No prior programming required for Chapter 1; later chapters assume its basic Python concepts.
Use the original localized explanations, exercises and checks already present in this activity; no external account or purchase is required for that fallback.
Compared Candidate Sources & Selection Analysis (2)
Guided Python syntax but assumes programming familiarity; paired with the beginner text rather than used as its replacement.
Lectures and problem sets teach a broader CS1 course; the book offers shorter text-first entry and an answer appendix.
Python Standard Library: Built-in Types
Relevant Section / Range: Sections Truth Value Testing, Comparisons, and Mutable Sequence Types
Verified Version & Date: Python 3.12 documentation (verified 2026-10-30)
Normative reference for truthiness, comparison, binding, and mutation behavior.
Day 03 recovery drill
Run the included Python examples and consult the installed interpreter help.
Compared Candidate Sources & Selection Analysis (2)
Deeper object-semantics reference than the expression-level drills need; stdtypes keeps the operator-level material in scope.
Narrative introduction to the same operators; the library reference was selected as the normative signature source.
Git User Manual: Recording Changes
Relevant Section / Range: Recording Changes to the Repository
Verified Version & Date: Verified 2026-10-30
Primary reference for inspecting a small diff before a safe commit.
Basic Git awareness
Use git diff and git status locally; do not commit until the diff is understood.
Compared Candidate Sources & Selection Analysis (2)
Command-level flag reference; the Pro Git chapter was selected for its guided walkthrough of inspecting changes before committing.
Friendly commercial walkthrough; the book chapter provides deeper staging/index semantics for the same inspection habit.