Python Design and Type Hints
Keep Missing, Zero, and Disabled Settings Separate
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
Fill only missing alert limits reads each limit field. North has no field, so use the supplied default of 25. South supplies 28, so keep it. Return [25, 28], in greenhouse order.
North has no alert limit field, so it uses the shared default of 25 degrees Celsius. South supplies its own limit of 28. Each greenhouse needs to keep the setting it requested when the default changes.
Inspect the component calculation
Fill only missing alert limits( Greenhouse settings: Greenhouse readings and alert settings Default limit in Celsius: Shared default limit in Celsius )
Examples and results
- Greenhouse readings and alert settings
- house
- north
- temperature_c
- 21
- limit
- Not provided
- house
- south
- temperature_c
- 30
- limit
- 28
house temperature_c limit north 21 Not provided south 30 28 - Shared default limit in Celsius
25
- Required result
- 025
- 128
- Greenhouse readings and alert settings
- house
- cold
- temperature_c
- -2
- limit
- -3
- house
- west
- temperature_c
- 8
- limit
- Not provided
house temperature_c limit cold -2 -3 west 8 Not provided - Shared default limit in Celsius
10
- Required result
- 0-3
- 110
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
The workshop displays Python's None as null. It assumes the supplied numerical settings are valid; the Python examples also explain how to validate them and distinguish an omitted function argument. 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.
An Exact Match Below Zero
This check uses the pieces from “Check Each Greenhouse with Its Own Limit”.
BOTIE
- Greenhouse readings and alert settings
- house
- east
- temperature_c
- 5
- limit
- Not provided
- house
- west
- temperature_c
- -2
- limit
- -2
- house
- lab
- temperature_c
- 100
- limit
- null
house temperature_c limit east 5 Not provided west -2 -2 lab 100 null - Shared default limit in Celsius
6
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 would replacing null with the default change a request to disable an alert?
Use a fallback only for the condition it is meant to handle.
The workshop displays Python's None as null. It assumes the supplied numerical settings are valid; the Python examples also explain how to validate them and distinguish an omitted function argument.