Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Python Design and Type Hints

Calculate an Alert Summary

Coding challenges

BOTIE

Keep readings at or above the limit returns [25, 30] from [20, 25, 30] when the limit is 25. Connect its output to Count items. A reading exactly at the limit still counts as an alert.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Keep readings at or above the limit returns [25, 30] from [20, 25, 30] when the limit is 25. Connect its output to Count items. A reading exactly at the limit still counts as an alert.

Readings of 20, 25 and 30 degrees Celsius arrive with an alert limit of 25. Two readings reach that limit. Together they are 5 degrees above it: the reading of 25 contributes zero, and 30 contributes five.

Inspect the component calculation
Count items(
  Items: Keep readings at or above the limit(
    Temperature readings: Celsius readings
    Alert limit: Alert limit in Celsius
  )
)
Examples and results
Celsius readings
  1. 020
  2. 125
  3. 230
Alert limit in Celsius
25
Required result
2
Celsius readings
  1. 010
  2. 115
Alert limit in Celsius
20
Required result
0
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

This workshop calculates a summary. It does not print a report, write a file or contact a web page. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

Zero Is a Real Alert Limit

This check uses the pieces from “Add the Total Above the Limit”.

BOTIE

The readings are [-5, 0, 8] degrees Celsius and the limit is 0. A reading exactly at the limit counts as an alert even though it adds no excess temperature.
Celsius readings
  1. 0-5
  2. 10
  3. 28
Alert limit in Celsius
0

Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Why can the text report change its wording without changing this calculation?

Keep the calculation separate from the code that displays or sends its result.

This workshop calculates a summary. It does not print a report, write a file or contact a web page.

Continue the courseDRY and Shared Rules →
← Names, Units, and Readable Code