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

Keep Names and Units in the Temperature Report

Coding challenges

BOTIE

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.
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

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
  1. house
    north
    temperature_c
    0
  2. house
    south
    temperature_c
    20
Celsius-to-Fahrenheit multiplier
1.8
Fahrenheit offset
32
Required result
  1. 032
  2. 168
Greenhouse temperatures in Celsius
  1. house
    cold
    temperature_c
    -10
Celsius-to-Fahrenheit multiplier
1.8
Fahrenheit offset
32
Required result
  1. 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

The current report lists attic at -40 degrees Celsius and lab at 37.5. Each converted reading still belongs to its named greenhouse.
Greenhouse temperatures in Celsius
  1. house
    attic
    temperature_c
    -40
  2. house
    lab
    temperature_c
    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.

Continue the courseFunctions with Clear Responsibilities →
← Keep Enough of a Calculation to Run It Again