Beta

Sync to cloud

Uses your current signed-in YoolVi account. A Learn profile is not required.

Upload a snapshot of this browser’s saved lesson work across all subjects, including notes, experiments, journal and review history. Existing guest work is included only when you confirm below. This does not upload account credentials or award XP.

Sync uploads to your private account; it does not automatically merge or replace this device’s work. On another device, download the cloud copy and use My Learning’s backup import. The previous cloud snapshot is retained when a new one replaces it.

Export or import this device’s work

No background uploads. Edits made after a snapshot need another sync. On shared devices, work is bound to the first account observed by cloud sync; another account must use a separate browser profile. Keep your own downloaded backup too.

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.

Trace a function and loop

Back to Programming for AI: Make It Run

Optional arithmetic and percentage refresher — return to this activity

A function packages a calculation so several orders can use the same rule. Its parameters are names for inputs. return sends a result back. An if branch chooses what to do under a condition; a for loop processes each item.

Python workshop: public teaching inputs

All people, records and numbers in this pack are authored teaching examples. They are not records or performance claims about real organizations.

  • PY1 · Price rows are [[2, 3], [4, 2]]: each row contains quantity then credits per item. Expected line totals are 6 and 8 credits. Lists use zero-based indexing: the first item has index 0.
  • PY2 · A function accepts input and returns a result. The supplied workshop demonstrates line_total(quantity, price). A branch selects an action; a loop repeats it. Negative quantity is rejected, not silently changed.
  • PY3 · A test compares observed behavior with an independently calculated expectation. A passing example alone is not proof for every input. Empty, zero and malformed inputs need stated behavior.
  • PY4 · Run the downloadable Python workshop locally. The page retains notes, not executed Python. Imported or pasted code is inert text. The separate reproducibility module supplies a second, scientific comparison starter.
Worked illustration · fixed teaching values

Follow one order through the calculation

row 0 · column 02 itemsorders[0][0]
row 0 · column 13 credits/itemorders[0][1]
line total6 credits2 * 3

The first index selects a row; the second selects a column. A second row [4, 2] contributes 8 credits: the running subtotal goes 0 → 6 → 14. Add a two-credit delivery fee once, after both rows, to get 16.

The values and their units travel together. A square table can keep the same shape even when its columns have the wrong meaning.

Read the code with the example

def names a function and its inputs. A colon starts an indented block; four spaces group statements. if chooses a branch. raise stops with an error. return sends the product back. for repeats the indented accumulation for each row. This short illustration checks quantity sign only; the downloadable program adds type and finite-number validation.

def line_total(quantity, price):
    if quantity < 0:
        raise ValueError("negative quantity")
    return quantity * price

total = 0
for row in [[2, 3], [4, 2]]:
    total = total + line_total(row[0], row[1])
print(total + 2)  # one delivery fee: 16

Fixed worked example, not an in-browser interpreter. Predict a changed input before running your own saved file.

Worked example

The supplied line_total function checks quantity is less than zero and raises ValueError for an invalid order. Otherwise it returns quantity * price. Calling it on [2, 3] then [4, 2] yields 6 and 8, whose sum is 14 credits. Indentation groups the function and branch statements.

Check the boundary

The downloadable program validates types and finite values as well as signs. Empty input is part of the contract: do not infer its behavior from the nonempty worked example. Preserve the original caller’s rows.