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 Missing, Zero, and Disabled Settings Separate

Coding challenges

BOTIE

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

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
  1. house
    north
    temperature_c
    21
    limit
    Not provided
  2. house
    south
    temperature_c
    30
    limit
    28
Shared default limit in Celsius
25
Required result
  1. 025
  2. 128
Greenhouse readings and alert settings
  1. house
    cold
    temperature_c
    -2
    limit
    -3
  2. house
    west
    temperature_c
    8
    limit
    Not provided
Shared default limit in Celsius
10
Required result
  1. 0-3
  2. 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

East uses the shared default of 6 degrees Celsius, west supplies its own limit of -2, and lab disables its alert. West also reads -2 degrees Celsius.
Greenhouse readings and alert settings
  1. house
    east
    temperature_c
    5
    limit
    Not provided
  2. house
    west
    temperature_c
    -2
    limit
    -2
  3. house
    lab
    temperature_c
    100
    limit
    null
Shared default limit in Celsius
6
Should west trigger an alert when its reading and its explicit limit are both -2 degrees Celsius? Answer true or false.

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.

Continue the courseDataclasses and Record Ownership →
← Type Hints and Function Contracts