The Gate Trials begin with a comparison. Before a program can choose a route, it needs a way to check a value. Start away from the gate with a community workshop that needs at least five paint tubes.
A comparison returns True or False, capitalized in Python. = assigns a value; == compares two values.
| Operator | Meaning |
|---|---|
== | equal to |
!= | not equal to |
> | greater than |
< | less than |
>= | greater than or equal to |
<= | less than or equal to |
The editable main.py starts with six paint tubes. Its first two checks print True and False: six is at least five, but is not equal to five.
The remaining lines combine checks about markers and paper. and requires both checks to be true; or requires at least one. not reverses a boolean, so not (markers == 0) asks whether the markers have not run out. The parentheses make the check being reversed clear.
Run the starter and read the last three lines: True, False, and True. Then make the two small edits in main.py.
paint_tubes to 4 while keeping the supplied comparisons. The first two lines should now both be False.paper_packs to 1 while keeping the combined checks. The final three lines should now be False, True, and True.Press Run after each edit, then Submit. The next exercise asks you to write checks for different supplies, rather than changing this demo's values.