Raw data, clear context.

[
[
[

]
]
]

We have three items in stock and need five. A useful first check is whether the available quantity meets the requirement. We can calculate that answer, give it a name and print it before deciding what the program should do next.

Ask one question

A Boolean represents a truth value. Python's bool type has two values, True and False, with capital initials.[1] For the integers used here, >= asks whether the left value is greater than or equal to the right value.[1]

Save this as stock-check.py. Run it from the same folder with your working Python launcher:

stock-check.py
Python
stock = 3
required = 5
enough = stock >= required
print(enough)
print(type(enough))
Run stock-check.py
Bash
python3 stock-check.py
Output
Plain text
False
<class 'bool'>

Python evaluates the comparison on the right of = and assigns its result to enough. In our run, three items failed the requirement of five, so the stored answer was False. The second printed line identifies its type as bool. Both examples were tested with Python 3.14.9 on Linux, using no extra packages.

A number line places stock at 3 and required at 5: 3 >= 5 gives False. At the boundary of 5, a filled endpoint shows >= includes 5 and gives True; an open endpoint shows > excludes 5 and gives False.
With three items available and five required, the check gives False. At exactly five items, >= gives True and > gives False. Filled and open endpoints show whether five is included.

Check the boundary

The numeric comparisons used below are < (less than), <= (less than or equal), > (greater than), >= (greater than or equal), == (equal) and != (unequal).[1] Save this second file as boundary.py:

boundary.py
Python
stock = 5
required = 5
print(stock < required)
print(stock <= required)
print(stock > required)
print(stock >= required)
print(stock == required)
print(stock != required)
Run boundary.py
Bash
python3 boundary.py
Output
Plain text
False
True
False
True
True
False

Each output line matches the comparison in the same position. With both quantities set to five, the inclusive comparisons <= and >= return True. The strict comparisons < and > return False. Equality succeeds; inequality fails. Testing this exact boundary helps catch a check that accidentally excludes the required quantity.

A common mistake

A single = assigns a value to a variable.[2] Use == to test equality.[1] If you replace an assignment with a comparison, the comparison asks a question and leaves the existing value alone. Keep the comparison inside print() when you want its answer displayed in a script.

Your turn

Change only stock = 3 in the first file to stock = 5, then to stock = 6. Predict both printed lines before each run. Check that enough becomes True in both cases. Next: use Boolean results with if, elif and else.

Sources

  1. Python 3.14: comparisons and Boolean type
  2. Python 3.14 tutorial: first steps towards programming