3.08 Iterations Homework: Themed Loop-Based Checker

Theme: a school server monitor. Each number is the load (as a percent) on a server. Low loads are safe and get skipped, higher loads need action, and the first critical load stops the scan.

Requirements

  • At least 8 values and 2 thresholds (safe_cutoff, critical_cutoff)
  • A for loop, continue to skip safe values, and break to stop at the first critical value
  • At least 3 tracked summary values (checked, skipped, action count, running total, critical found)
  • A clearly labeled final report

Submission safety rules

  • One CodeRunner task per cell, with the # CODE_RUNNER: line at the top
  • Run each cell and leave the output showing
  • Use your own values, include your MCQ score, and use ## headings or smaller

Description box (paste when submitting)

Code Runner Challenge

Homework Hack - school server load checker

View IPYNB Source
Lesson: Python 3.08 Iterations
MCQ 3.08: <paste the copied result line, such as 4/4 | answers: A,B,A,B>
Popcorn: completed loop variable, thresholds, counters, continue, and break (yes/no)
Homework: list length = 9
Homework: thresholds = 40 and 85
Homework: final checked count = 7
Homework: final action count = 4
Homework: critical found = yes
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...
# CODE_RUNNER: Homework Hack - school server load checker

# Theme: a school server monitor. Each number is a server's load in percent.
server_loads = [22, 35, 48, 15, 67, 54, 91, 40, 77]

# Loads below safe_cutoff are skipped with continue
safe_cutoff = 40

# Loads at or above critical_cutoff stop the loop with break
critical_cutoff = 85

# Summary variables (all start at 0 because nothing has been processed yet)
checked_count = 0
action_count = 0
skipped_count = 0
total_score = 0
critical_found = False

for load in server_loads:
    checked_count += 1

    # Safe load: count it, say so, and skip to the next server
    if load < safe_cutoff:
        skipped_count += 1
        print("Server load " + str(load) + "%: safe, skipping")
        continue

    # Needs action: count it and add it to the running total
    action_count += 1
    total_score += load
    print("Server load " + str(load) + "%: needs attention")

    # Critical load: stop the whole scan so the team can focus
    if load >= critical_cutoff:
        critical_found = True
        print("Critical server load found: " + str(load) + "%. Stopping the scan.")
        break

print("--- Final Report ---")
print("Servers in list:", len(server_loads))
print("Servers checked:", checked_count)
print("Servers skipped as safe:", skipped_count)
print("Servers needing action:", action_count)
print("Total load of action servers:", total_score)
print("Critical found:", critical_found)