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

Secure a tiny inventory handler

Does parsing a numeric prefix enforce a whole-input contract?

Entering midway? Revisit Who can read the payroll? for the preceding worked example, or start here and use the explanation below.

1 · Try

Start with a concrete question

Safe inert request inspection: quantities must be whole decimal strings from 1 to 20. No input is executed.

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?

Before changing a setting: Does parsing a numeric prefix enforce a whole-input contract? Write what you expect and why.

3 · Experiment

Change one thing. Inspect what happens.

  1. Try the valid quantity through each boundary.
  2. Predict what happens to “12 extra” under prefix parsing.
  3. Inspect markup-like text; distinguish validation from safe display.
  4. Write pseudocode and test cases for the contract.
Experiment inputs
Inputs
Your settings
Mechanism
Calculation below
Evidence
Compare outcomes
Accepted request1 request
Invalid requests accepted0 request
Raw markup rendered0 unsafe render

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.
01
  • Accepted request (request)1
    Accepted request (request): 1Horizontal bar from zero to 1, on the shared zero to 1 numeric axis.
  • Invalid requests accepted (request)0
    Invalid requests accepted (request): 0Horizontal bar from zero to 0, on the shared zero to 1 numeric axis.

Follow the calculation

  1. Submitted inert text: 12. Contract: a whole decimal quantity from 1 to 20.
  2. No checks; display raw input.
  3. Fixture handler accepts the request.
  4. This model compares policies without evaluating or rendering learner text as code.

Validate the complete input at the application boundary and encode output for its context; numeric prefix parsing does not enforce the whole contract.

Repair a sandbox inventory authorization handler

Repair accept(role, quantity). Role 0 is visitor, 1 editor, 2 administrator; only editors and administrators may update stock. Quantity is an already-parsed number and must be an integer from 1 to 20. Run the supplied cases, then add your own. This subset exercise does not parse raw strings or implement a deployed server; the fixture above teaches that separate boundary.

367/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 accept(role, quantity) {
  return quantity > 0;
}
print("visitor", accept(0, 12), "expected false");
print("editor", accept(1, 12), "expected true");
print("too large", accept(2, 21), "expected false");
print("fraction", accept(1, 2.5), "expected false");
print("zero", accept(1, 0), "expected false");
print("unknown role", accept(9, 12), "expected false");

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

Inspect an example solution after your attempt
function accept(role, quantity) {
  return (role === 1 || role === 2) && quantity >= 1 && quantity <= 20 && quantity % 1 === 0;
}
print("visitor", accept(0, 12), "expected false");
print("editor", accept(1, 12), "expected true");
print("too large", accept(2, 21), "expected false");
print("fraction", accept(1, 2.5), "expected false");
print("zero", accept(1, 0), "expected false");
print("unknown role", accept(9, 12), "expected false");

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

Secure a tiny inventory handler

Safe inert request inspection: quantities must be whole decimal strings from 1 to 20. No input is executed.

Follow the mechanism

A numeric parser may accept a prefix while ignoring trailing text.

Output encoding prevents text from being interpreted as markup; it is distinct from validating a quantity.

This local simulator never evaluates code and cannot secure a deployed application for you.

Worked example

Submitted inert text: 12. Contract: a whole decimal quantity from 1 to 20.

No checks; display raw input.

Fixture handler accepts the request.

This model compares policies without evaluating or rendering learner text as code.

Calculation

Accept = entire input matches decimal digits AND 1 ≤ numeric quantity ≤ 20.

Try a controlled comparison

  1. Try the valid quantity through each boundary.

  2. Predict what happens to “12 extra” under prefix parsing.

  3. Inspect markup-like text; distinguish validation from safe display.

  4. Write pseudocode and test cases for the contract.

What this does not establish

  • All messages, people, documents and outcomes here are original fictional teaching fixtures; results are not measurements of real organizations.
5 · Apply

Try a fresh case

A quantity contract accepts integers 1 through 20. For inputs 0, 1, 12, 21, how many should be accepted?

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

Create a new case with different numbers and explain your decision to a classmate.

College investigation

Implement or analyze a fresh case, document assumptions and compare at least two alternatives.

Workplace investigation

Prepare a decision artifact with evidence, operating constraints, an owner and a follow-up measurement.

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.