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

Check the Values Entering the Converter

Coding challenges

BOTIE

Keep actual finite numerical readings, then convert them from Celsius to Fahrenheit. Leave out text, booleans and null. Keep zero and repeated numerical readings. Return the converted temperatures in their original order.
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

Keep actual finite numerical readings, then convert them from Celsius to Fahrenheit. Leave out text, booleans and null. Keep zero and repeated numerical readings. Return the converted temperatures in their original order.

The Celsius-to-Fahrenheit converter works on numbers. Botie needs to decide what enters it when a file supplies other kinds of values.

Keep numerical readings passes actual numbers through unchanged and leaves other values out. Put it before the familiar Multiply and Add conversion. In the first example all readings are numerical, so the check should leave [0, 20] intact.

Examples and results
Incoming Celsius values
  1. 00
  2. 120
Celsius-to-Fahrenheit multiplier
1.8
Fahrenheit offset
32
Required result
  1. 032
  2. 168
Incoming Celsius values
[]
Celsius-to-Fahrenheit multiplier
1.8
Fahrenheit offset
32
Required result
[]
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 construction checks values while it runs. It does not execute a static type checker. The deliberate policy here skips unusable values; a later lesson will require rejecting an entire invalid batch. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Repeated and Fractional Readings

This check uses the pieces from “Check Readings before Converting Them”.

BOTIE

The new file contains [4.5, false, 4.5, -40]. The numerical-only rule still applies, and repeated measurements are separate readings.
Incoming Celsius values
  1. 04.5
  2. 1false
  3. 24.5
  4. 3-40
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.

What information does a type hint give another programmer, and what extra work does the running value check perform?

State the expected values in the interface and choose an explicit response when incoming data does not match.

This construction checks values while it runs. It does not execute a static type checker. The deliberate policy here skips unusable values; a later lesson will require rejecting an entire invalid batch.

Continue the courseMissing Values, Defaults, and None →
← DRY and Shared Rules