Challenge
Silent branch
status_light() returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function…
8 results
Challenge
status_light() returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function…
Challenge
…so CRITICAL can never run. Predict it, find the dead branch, fix the order, then write a four-level chain.
Challenge
Replace a nine-branch elif that maps planets and the Moon to surface gravity with a dict and one get() lookup, keeping the output exactly the same, then loop over the dict for a weight table.
Article Python Fundamentals
…conditions top to bottom and executes the first true branch. Once a branch runs, the rest are ignored. Common condition types Here's what you'll use most often when writing conditions: Comparisons: ==…
Challenge
…loop, add 1 to the right one inside the WARN and CRITICAL branches, and print the summary after the loop, at the left edge.
Challenge
…"From 400" includes 400 itself, so use >= . Indent each branch's line by four spaces. A status line The console shows the sensor, the reading and the level on one line. Add sensor = "ENG-2" under the…
Quiz
…questions that check you can follow a condition to the branch that runs, and spot the mistakes beginners make most often. What the quiz covers if , else and elif , and which branch runs Comparison…
Challenge
…(TBD), Polaris Cargo 4 (Hold) Build a list in the else branch, then join it after the loop.