Python Design and Type Hints
Connect a New Thermometer to the Alert Counter
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
Multiply each incoming reading by the supplied calibration multiplier, then add the offset. The first thermometer uses 1 and 0, leaving [10, 14, 18] unchanged. Keep these inputs as wires so a replacement can supply a different correction.
The existing alert counter expects Celsius readings. A replacement thermometer needs a correction before its readings reach that counter. The supplied multiplier and offset describe that correction; the alert rule itself still uses the same Celsius limit.
Inspect the component calculation
Add(
First contribution: Multiply(
Value: Incoming thermometer readings
Multiplier: Calibration multiplier
)
Second contribution: Calibration offset in Celsius
)Examples and results
- Incoming thermometer readings
- 010
- 114
- 218
- Calibration multiplier
1
- Calibration offset in Celsius
0
- Required result
- 010
- 114
- 218
- Incoming thermometer readings
- 02
- Calibration multiplier
1
- Calibration offset in Celsius
0
- Required result
- 02
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 correction is supplied for these invented thermometers; the workshop does not estimate a real calibration. It illustrates composing calculations. The Python examples introduce replaceable source and sink objects. 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.
The Correction Reverses the Reading Order
This check uses the pieces from “Connect the Corrected Readings to the Counter”.
BOTIE
- Incoming thermometer readings
- 0-3
- 14
- Calibration multiplier
-2
- Calibration offset in Celsius
10
- Alert limit in corrected Celsius
10
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.
Where would you make a change if a third thermometer needed a different correction, and which components could remain?
Keep the device-specific work outside the calculation that uses its results.
The correction is supplied for these invented thermometers; the workshop does not estimate a real calibration. It illustrates composing calculations. The Python examples introduce replaceable source and sink objects.