topskill.dev
CoursesTracks
0
All courses/Python Basics: The Lantern AtlasDemo: Compare Workshop Supplies
Level 3: Gate Trials — Decisions and Loops
1 / 12
← Python Basics: The Lantern Atlas
○Level 1: Spawn Camp○Demo: Light the Camp Message○Exercise: Open the Lantern Map○Code Comments○Demo: Name a Map Location○Exercise: Label a Beacon○Variable Types○Demo: Inspect Lantern Types○Exercise: Pack Starting Supplies○Optional: Set up Python Locally✦Module Quiz
○Demo: Divide Beacon Shards○Exercise: Price a Cache Route○Demo: Format a Gear Label○Exercise: Format Forge Readouts○Demo: Convert Shard Text○Exercise: Convert Charge Readings○Demo: Read a Pathfinder Name○Project: Build Adi’s Gear HUD✦Module Quiz
●Demo: Compare Workshop Supplies○Exercise: Check Gate Supplies○Demo: Choose a Lit Route○Choose a Gate Signal○Demo: Pulse a Beacon with while○Exercise: Recharge the Beacon○Demo: Mark a Route with range○Exercise: Label Even Patrols○Demo: Skip a Hazard, Stop at a Gate○Exercise: Cross Safe Tiles○Project: Unlock the Exit Gate✦Module Quiz
○Define a Beacon Ability: Demo○Exercise: Activate a Beacon○Pass Energy and Return a Result: Demo○Exercise: Combine Beacon Energy○Default Ability Marks: Demo○Exercise: Name a Beacon Ability○Local Energy Scope: Demo○Exercise: Spend Local Energy○Project: Build an Ability Loadout✦Module Quiz
○Read a Rune Code: Demo○Exercise: Read Rune Edges○Slice a Cavern Route: Demo○Exercise: Decode Route Fields○Clean a Rune Message: Demo○Exercise: Decode a Rune Notice○Format a Route Card: Demo○Exercise: Write a Decoded Route Sign✦Module Quiz
○Index a Gear List: Demo○Exercise: Build a Gear Queue○Change a Gear List: Demo○Exercise: Repair the Loadout○Slice a Ridge Route: Demo○Exercise: Pack for Checkpoints○Read a Fixed Checkpoint Record: Demo○Exercise: Read an Exit Checkpoint✦Module Quiz
○Read an Atlas Map Card○Exercise: Update a Map Entry○Loop Through Beacon Map Entries○Exercise: Count Cache Marks○Count Unique Atlas Stops○Exercise: Compare Atlas Routes○Demo: Summarize Beacon Finds○Exercise: Build the Atlas Treasure Index✦Module Quiz
○Recover a Faded Beacon Reading○Exercise: Label Beacon Charge○Demo: Write a Shrine Save○Exercise: Save a Beacon Signal○Mini Project: Restore the Save Shrine✦Module Quiz
○Demo: Calculate Beacon Capacity○Exercise: Calculate Lantern Capacity○Demo: Import a Local Beacon Rule○Exercise: Import a Shrine Rule○Demo: Follow a Dotted Package Import○Exercise: Read an Atlas Record✦Module Quiz
○Echo Tower: The Base Case○Echo Tower: Sum the Signals○Echo Tower: Tune the Frequencies○Echo Tower: Select Beacon Labels✦Module Quiz
○Exit Gate: Reading Object Vocabulary○Final Game Mission: Open the Exit Gate✦Module Quiz

Demo: Compare Workshop Supplies

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.

OperatorMeaning
==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.

Your Task

  1. Change paint_tubes to 4 while keeping the supplied comparisons. The first two lines should now both be False.
  2. Change 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.

Files
  • ⋄main.py
Loading editor…
Press Run to execute your code.