Results for “branches”

8 results

  1. 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…

    Fix the code Easy 3 stages functions return None branches
  2. Challenge

    Lookup table

    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.

    Fix the code Medium 2 stages dictionaries refactoring lookup tables get
  3. Article Python Fundamentals

    Python If/Else for Beginners

    …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: ==…

  4. Challenge

    Check every reading

    …loop, add 1 to the right one inside the WARN and CRITICAL branches, and print the summary after the loop, at the left edge.

    Write the code Easy 2 stages for loop lists if elif
  5. Challenge

    Alert level

    …"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…

    Write the code Easy 2 stages if elif else comparisons