thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

03.19 · Python basics / Practice · 8 min

Make the Boolean name explain the answer

True is useful only when the reader knows what is true. Replace a vague name with the question your program is answering.

Activity 19 of 19 in Python basics

All courses

Python Basics / 03.19

Name Boolean values clearly

Not started

Choose meaningful snake_case names for Boolean state and permission, then update every reference consistently.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob replaces the vague name x with has_submission, distinguishes it from is_assigned, and reads can_review as their combined Boolean answer.
Rob’s comic strip · Python basics

Read the name as a yes-or-no question

Names such as is_ready, has_submission and can_review suggest a state, the presence of something or a permission. Use lowercase words separated by underscores, following the snake_case style used for Python variables.

These prefixes help a person read your code; they do not change how Python evaluates it. is_ready = "yes" would still store a string. Keep Boolean state as actual True/False values or an expression that produces them.

Descriptive names give True and False their context
boolean_names.pypython · example
is_ready = True
has_submission = False
can_review = is_ready and has_submission

print(can_review)  # False

Prefer a positive question and avoid double negatives

A name such as has_submission makes it clear what True means: a submission exists. A name such as is_not_missing_submission makes the same state harder to follow, especially when another not is added later.

Choose the wording that accurately describes your domain; positive names are a readability preference, not a language restriction. Avoid vague names such as flag or x when a short meaningful phrase fits.

Presence and permission answer different questions
boolean_names.pypython · example
has_submission = True
is_assigned = False
can_review = has_submission and is_assigned

print(has_submission)  # True
print(can_review)  # False

Rename every reference without changing the behavior

Renaming a variable means updating both its assignment and each place that reads it. If you leave the old name in an expression, Python can raise NameError. A name change alone should not change the program’s result.

In the exercise below, x means that a submission exists. Rename it to has_submission, keep is_assigned as False and update can_review to read the descriptive name. The output should stay False because the reviewer has not been assigned.

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

4 steps · Saved work · Instant feedback

YOUR TURN

Replace x with a meaningful Boolean name

Rename x to has_submission where it is assigned and where can_review reads it. Keep its Boolean value True. Keep is_assigned set to False, keep the and expression and keep print(can_review). To pass: has_submission must hold True, is_assigned must hold False, can_review must hold False, and the program must print False exactly once. This is a rename; the behavior should stay the same.

Expected output
False

Keep the starting inputs. Print these lines in this order, without extra output.

  • has_submission holds the Boolean True
  • is_assigned still holds the Boolean False
  • can_review holds the Boolean False

Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Need a nudge?

Update the assignment and the use

The old name appears on the first line and in the can_review expression. Use has_submission in both places.

A clear name should preserve the answer

A submission exists, but the reviewer is not assigned. Both conditions are required, so can_review stays False.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

You made the question readable while preserving the answer. The source Python Basics string and number challenges follow these topics.