Python Design and Type Hints
Keep Names and Units in the Temperature Report
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
Read temperatures in Celsius takes temperature_c from each row. For [0, 20], multiply by 1.8 and then add 32 to obtain [32, 68]. Use Multiply and Add, as in the earlier conversion workshop.
The north greenhouse reads 0 degrees Celsius and the south reads 20. Their Fahrenheit readings are 32 and 68. The report also needs to say which greenhouse each value belongs to and which unit it uses.
Inspect the component calculation
Add(
First contribution: Multiply(
Value: Read temperatures in Celsius(
Greenhouse records: Greenhouse temperatures in Celsius
)
Multiplier: Celsius-to-Fahrenheit multiplier
)
Second contribution: Fahrenheit offset
)Examples and results
- Greenhouse temperatures in Celsius
- house
- north
- temperature_c
- 0
- house
- south
- temperature_c
- 20
house temperature_c north 0 south 20 - Celsius-to-Fahrenheit multiplier
1.8
- Fahrenheit offset
32
- Required result
- 032
- 168
- Greenhouse temperatures in Celsius
- house
- cold
- temperature_c
- -10
house temperature_c cold -10 - Celsius-to-Fahrenheit multiplier
1.8
- Fahrenheit offset
32
- Required result
- 014
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
These supplied readings are valid Celsius measurements. A field name explains the intended unit; it cannot establish whether a real thermometer used that unit. 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.
Below Freezing and Between Whole Degrees
This check uses the pieces from “Attach the Greenhouse Names”.
BOTIE
- Greenhouse temperatures in Celsius
- house
- attic
- temperature_c
- -40
- house
- lab
- temperature_c
- 37.5
house temperature_c attic -40 lab 37.5 - Celsius-to-Fahrenheit multiplier
1.8
- Fahrenheit offset
32
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.
If the report returned a field called value instead of temperature_f, what would another reader have to guess?
Keep names and units explicit as the report gains more calculations.
These supplied readings are valid Celsius measurements. A field name explains the intended unit; it cannot establish whether a real thermometer used that unit.