Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Learn through experiments

Build a price calculation tool

Does changing calculation order preserve the contract?

1 · Try

Start with a concrete question

An original synthetic invoice has base prices 10,20,30. The contract adds percentage tax to each base price, then an untaxed flat fee. Implement the rule in the linked code runner.

Try the initial inputs, then write a prediction before changing one setting. All calculations run locally on your CPU.

Go directly to the experiment · Review basic mathematics

2 · Predict

What do you expect?

Predict whether taxing a fee accidentally matters when fee or tax is zero.

3 · Experiment

Change one thing. Inspect what happens.

  1. Calculate the first item manually, then inspect the loop trace.
  2. Switch implementation order and find cases that hide the bug.
  3. Copy the starter in the explanation into the code runner; repair it and print all three charges and their total.
Experiment inputs
Inputs
Your settings
Mechanism
Calculation below
Evidence
Compare outcomes
Invoice total72 credits
Extra fee tax compared with contract0 credits

Compare the current results

Every bar starts at zero and uses the same numeric scale in this chart. The upper bound automatically adjusts to the largest current value (at least 1), so compare the numbers when changing inputs. Units and quantities come from each label; different kinds of quantity are not interchangeable. Displayed values are rounded to at most six significant digits.
035
  • Item 10 final charge13
    Item 10 final charge: 13Horizontal bar from zero to 13, on the shared zero to 35 numeric axis.
  • Item 20 final charge24
    Item 20 final charge: 24Horizontal bar from zero to 24, on the shared zero to 35 numeric axis.
  • Item 30 final charge35
    Item 30 final charge: 35Horizontal bar from zero to 35, on the shared zero to 35 numeric axis.

Follow the calculation

  1. Price 10: price × (1 + rate) + fee = 13 credits.
  2. Price 20: price × (1 + rate) + fee = 24 credits.
  3. Price 30: price × (1 + rate) + fee = 35 credits.

The contract taxes the item, then adds an untaxed fee. Reordering operations changes the result; named intermediate values make it inspectable.

Implement the invoice tool

Repair the charge function so the fee is untaxed. Print each charge and the total. Then add a zero-tax test and explain why that test alone cannot detect the bug. Expected default outputs: 13, 24, 35, 72. Use Run; a printed match is practice, not a proof of correctness.

237/8,000 characters. Drafts save locally and are included in backups. Importing or opening a draft never runs it.

Bounded JavaScript subset: variables, primitive arrays, conditions, loops, functions and print. No browser objects, network, imports or eval. Maximum 10,000 operations, 64 array items, call depth 16, strings of 256 characters, 40 output lines / 4,000 output characters and 160 trace frames.

Compare with my earlier draft
function charge(price, rate, fee) {
  return (price + fee) * (1 + rate);
}
const prices = [10, 20, 30];
let total = 0;
for (const price of prices) {
  const value = charge(price, 0.1, 2);
  print(value);
  total += value;
}
print(total);

Explain what you changed and why in your observation notes. Text differences do not establish quality.

Inspect an example solution after your attempt
function charge(price, rate, fee) {
  return price * (1 + rate) + fee;
}
const prices = [10, 20, 30];
let total = 0;
for (const price of prices) {
  const value = charge(price, 0.1, 2);
  print(value);
  total += value;
}
print(total);

This is one worked example. Test another input and explain its limitations.

Captures keep your inputs, prediction and observation. Results are recalculated from those inputs. Resetting inputs keeps your captures and challenge history.

4 · Understand

Explain the mechanism

Build a price calculation tool

An original synthetic invoice has base prices 10,20,30. The contract adds percentage tax to each base price, then an untaxed flat fee. Implement the rule in the linked code runner.

Predict before changing inputs

Predict whether taxing a fee accidentally matters when fee or tax is zero.

Understand the mechanism

A tool needs an input contract and an output contract. Here the fee is explicitly untaxed; putting it inside the multiplication violates the rule.

For price 10, tax 10% and fee 2, the correct result is 10×1.1+2=13. The incorrect taxed-fee expression produces 12×1.1=13.2.

Use named intermediate values and test more than one case. Default total is 13+24+35=72 credits.

Calculate it yourself

Final charge = base price × (1 + tax fraction) + untaxed fee.

Guided investigation

  1. Calculate the first item manually, then inspect the loop trace.

  2. Switch implementation order and find cases that hide the bug.

  3. Copy the starter in the explanation into the code runner; repair it and print all three charges and their total.

Assumptions and limitations

  • Rates and money are fictional; this is not tax advice or a production currency library.

  • JavaScript uses binary floating-point. Real financial tools need explicit rounding and currency-unit rules.

Further investigations

High school: Build a small event-cost calculator and show sample inputs and outputs.

College: Implement a pure function and tests for zero fee, zero rate and multiple items.

Working professionals: Document a pricing interface contract including rounding, invalid input and ownership.

Your implementation or data task

Repair the charge function so the fee is untaxed. Print each charge and the total. Then add a zero-tax test and explain why that test alone cannot detect the bug. Expected default outputs: 13, 24, 35, 72. Use Run; a printed match is practice, not a proof of correctness.

Use the editable workspace on this page. Its output is practice evidence; explain why it satisfies the contract and test a fresh case.

5 · Apply

Try a fresh case

A new item costs 40, tax is 20%, and an untaxed fee is 3. What is its charge?

This is a public practice check. Retries support learning; matching a number does not certify independent proficiency.

Take the investigation further

Choose any extension. These are project prompts for you to carry out; they are not automatically assessed.

School investigation

Build a small event-cost calculator and show sample inputs and outputs.

College investigation

Implement a pure function and tests for zero fee, zero rate and multiple items.

Workplace investigation

Document a pricing interface contract including rounding, invalid input and ownership.

6 · Continue

Keep the evidence, choose your next step

Completion records your own decision that you have worked through this investigation. Practice checks and independent project evidence are separate.