Python Design and Type Hints
Calculate an Alert Summary
BOTIE
Examples, experiments and workspace controls
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.
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
- 020
- 125
- 230
- Alert limit in Celsius
25
- Required result
2
- Celsius readings
- 010
- 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
- Celsius readings
- 0-5
- 10
- 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.