Think in small programs
Turn an everyday question into input, transformation and output.
Save privately stores your edited code, notes and current section. Runs and public checks are not saved as verified scores.
Before you start
Learners building Python foundations; revisit the preparation topics whenever the vocabulary is unfamiliar.
Explore the connected curriculum and preparation map
Lesson content version 2026-10-27. Suggested core budget: 8 minutes; optional deep dive: 5 more minutes. These are reading/practice estimates, not a timed test.
No earlier Python lesson is required. Start with the small worked example; installation is not needed for supported browser snippets.
Actual runtime and local-lab boundaries
Browser Python 3.13: fresh isolated worker, 4-second execution, 16 KiB output, 256 MiB Python heap; no outbound network, host processes, interactive input or package installation.
Supported snippets run in the browser; temporary files and SQLite data disappear after each run. Models are labelled conceptual, not traces of your edited source. Full operating-system/framework/cloud labs need separate approval.
Public checks, revealed answers and project self-checks are learning feedback, not verified mastery or problem acceptance. Saving code does not execute it.
- Read a program top to bottom
- Use print and comments
- Separate a value from its displayed form
A program is a sequence of decisions
A program is a set of precise instructions for turning supplied information into a result. Start by stating the question, not by guessing syntax.
Understand first
A small calculation is a useful first program because you can check it by hand. The same input, transformation and output structure later appears in file processing and web services.
Words you will see
- Input
- Information the calculation starts with; it need not come from a keyboard.
- Statement
- An instruction such as assigning a name or displaying a result.
- Expression
- Code that produces a value, such as price * people.
Write the rule before the code
For a lunch budget, the question is how much lunch costs for several people. The inputs are price per person and the number of people. The rule multiplies them. The output is the total, in the same currency unit as the price. Naming those pieces prevents an accidental rule such as adding price and people.
You can supply inputs directly as values while learning. External input, validation, discounts and currency rounding are separate decisions. Start with a rule small enough to verify, then extend it with explicit requirements rather than hiding several ideas in one line.
Execution order makes the result explainable
Python normally executes these statements from top to bottom. price = 8 gives the name price a value. total = price * people reads the currently supplied values and stores their product. print(total) makes that result visible. Changing an input afterwards does not automatically recalculate an earlier total.
A line beginning with # is a comment for the reader, not another calculation. Blank lines help organisation but do not change this program's result. Code must be precise enough that you can trace the values after each statement; a computer does not infer a missing business rule from the variable names.
The original example, step by step
These steps explain the original code below. They do not change when you edit your own experiment.
price = 8Supply the per-person price.
people = 3Supply the number of people.
total = price * peopleMultiply 8 by 3 and store 24.
print(total)Display the already calculated total.
Start with a tiny useful question: what does lunch cost for three people? Describe the inputs, the transformation and the result before typing. Python executes statements in order; a comment beginning with # is for humans, not an instruction.
A calculation has three responsibilities
Conceptual reasoning steps for the original example, not a live trace of your edited Python.
- Supplyprice = 8 and people = 3
- Transform8 * 3 produces 24
- Observeprint displays 24
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Change one thing; explain the difference.
Recalculate for four people.
Try: Change people = 3 to people = 4 before the multiplication.
The total becomes 32.
Test execution order.
Try: Add people = 4 after total is calculated but before the print.
The total stays 24 because the earlier expression is not automatically repeated.
Before you move on
If total is calculated for three people, then people becomes four before print(total), what prints?
Try explaining it in your own words. Running code is useful, but the explanation above gives you enough to reason it through first.
Read a worked answer
It still prints 24. The previous multiplication already produced that value. Move or repeat the calculation after changing people to calculate 32.
Your first useful calculation
Use print to observe a calculated value. A script can successfully calculate a value without displaying it unless you explicitly ask.
Understand first
Clear output lets a learner compare a prediction with what actually happened. Separating calculation from presentation also makes the rule easier to reuse and test.
Words you will see
- Literal
- A value written directly in source, such as 8 or "Lunch total:".
- String
- A text value, written in quotes here.
- Argument
- A value supplied to a call such as print.
Read every visible part of the call
print("Lunch total:", total) supplies two arguments. The first is a text label and the second is the current value of total. print normally separates its arguments with a space and ends with a newline. The quotes mark the string in source; they are not printed as part of this label.
The multiplication runs before the final print statement. A comment describes why the calculation exists but does not execute. Changing the comment cannot change the total. Changing a numeric input before the calculation can.
A display is not the underlying value
The integer 24 and the string "24" can look the same when printed, but they support different operations. Adding two integers calculates a numeric sum; joining strings joins text. Keep numeric inputs numeric when you intend arithmetic, rather than relying on what a printout happens to look like.
In an interactive Python prompt, entering a bare expression usually displays its representation. In a script, a bare expression is evaluated but not automatically shown. Our Run editor executes a script, so use print when you want to inspect a value. Later exercises will distinguish a function's returned value from displayed output.
To create text for later use instead of immediately printing it, an f-string inserts values into braces. For example, label = f"Total: {total}" stores the text "Total: 24" when total is 24. The leading f activates interpolation; {total} evaluates the name and formats its value. This does not change the numeric total itself. The guided label exercise uses this spelling inside a small function, whose def/return wrapper is explained before practice.
The original example, step by step
These steps explain the original code below. They do not change when you edit your own experiment.
price = 8Store an integer, not a quoted digit string.
# Calculate first; display second.Give the reader a note; Python does not run the comment.
total = price * peopleCalculate the total using the two supplied numbers.
print("Lunch total:", total)Display a label and the total separated by a space.
Use print to make a value observable. Strings describe things; numbers let you calculate. A script does not automatically display every expression the way an interactive prompt may.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Change one thing; explain the difference.
Observe a script without printing.
Try: Remove the final print and run.
Actual output reports no stdout; that is not proof that the calculation did not run.
Separate the label from the value.
Try: Use print(total), then print("Lunch total:", total).
Both display the same numeric total, with different presentation.
Before you move on
If print is removed but total = price * people remains, did the calculation stop working?
Try explaining it in your own words. Running code is useful, but the explanation above gives you enough to reason it through first.
Read a worked answer
No. The assignment still calculates and stores 24. The script simply produces no visible stdout unless another statement displays something.
When to use a script
A script is a saved program you can run again. Repeating a task reliably matters more than starting with a large framework.
Understand first
A repeatable budget calculation, rename plan or small report can be a short script. You should be able to state its inputs and command before adding a service, website or dependency.
Words you will see
- Script
- A file containing instructions run as a program.
- Runtime
- The execution environment that runs the source.
- Standard library
- Modules supplied with Python; available capabilities still depend on the platform.
Make the repeated task explicit
Suppose lunch is needed on several days. The calculation now has three inputs: price, people and days. Naming days makes the extra requirement visible. Multiplication is still the whole rule; a framework would not make it more correct.
Save a local script with a .py extension and run that exact file using the intended interpreter. On Windows, py budget.py often selects Python; python3 budget.py is common elsewhere. Those are terminal commands, not Python expressions to paste into this editor. Availability and launcher settings differ by machine.
Know which machine the script actually uses
Run here executes in an isolated browser worker. It is not your host Python installation and cannot inspect host files, install packages or contact a remote service. Download the file for a suitable local environment when the task needs those capabilities. The browser's temporary files disappear after a run.
A deterministic script gives the same visible result for these explicit fixed inputs. Time, random input, external state and version-sensitive behavior can change that promise. Start with explicit values so that a failure can be traced to a rule rather than an unseen environment change.
The original example, step by step
These steps explain the original code below. They do not change when you edit your own experiment.
days = 2Add the second dimension of the repeated task.
print(price * people * days)Multiply the three current inputs and display 48.
A short script is useful for repeatable calculations, file processing and small automation. Do not start with a web framework when a few explicit steps solve the problem. Save code in a .py file and run python3 filename.py (or py filename.py on Windows).
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Change one thing; explain the difference.
Represent one day.
Try: Set days = 1.
The answer becomes 24.
Represent no planned days.
Try: Set days = 0.
The result is zero under this multiplication rule; whether that is valid input is a separate contract decision.
Before you move on
Would downloading this program make it dependent on a web framework? What must a local run provide?
Try explaining it in your own words. Running code is useful, but the explanation above gives you enough to reason it through first.
Read a worked answer
No framework is needed. A local run needs a compatible Python interpreter, the saved file and the intended input values. Browser-only execution and the host interpreter are different environments.
Where this idea earns its place
A useful first program replaces a repeatable manual calculation, not an entire application. Imagine a team lunch: the number of people and the per-person price are inputs, multiplication is the transformation, and the total is the result. Writing those three pieces down exposes missing decisions such as currency, rounding and whether tax is already included.
Follow the mechanism step by step
When the script runs, Python evaluates the price literal and binds its value to price, then does the same for people. The expression price * people reads those bindings and produces a result. Binding total does not display it; print is a separate observable action. In a REPL, automatic expression display can hide that distinction, so reproduce the same calculation in a saved file.
Work through a concrete application
Start with known whole-number inputs and predict the result on paper. Run the file from its own directory, compare stdout with the prediction, then change only people. Once that works, wrap the transformation in a function so another caller can reuse it without printing. Add input parsing only after the calculation itself has a clear contract.
Failure cases and misleading shortcuts
A syntax error means Python could not construct the program for that unit; changing unrelated values will not repair missing punctuation or indentation. A runtime error occurs when an executed operation fails. Also distinguish printing a quoted expression from evaluating it: the text 'price * people' is not a request for arithmetic. Keep explanatory comments consistent with code changes.
Cost, ownership and alternatives
For a fixed small calculation, execution and memory requirements are tiny; terminal startup and human interaction dominate. That observation does not justify using this script structure for millions of records. A future loop changes the cost model, and a future money calculation requires an explicit representation and rounding policy rather than an accidental float default.
Verify the contract
Use at least two ordinary examples and a meaningful boundary such as zero people. Decide whether negative counts should be rejected rather than simply showing a negative bill. Check exact stdout only for the presentation contract; test the returned number directly once calculation is extracted. Keep Python version and the launch command in your notes so another person can reproduce the exercise.
Transfer question: How would you evolve this into a reusable calculator without making every call print?
Extract a function taking price and people and returning their product, validate the agreed input rules at an appropriate boundary, and leave print in the script entry point. Test the function with numbers and test one CLI presentation separately. This separates computation from display without introducing an unnecessary framework.
Can you explain it?
Try from memory. Feedback stays on this page and does not award judged progress.
A team snack budget
Four people each buy a snack costing 6. Print the total as a number.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Guided practice and transfer
These are public local learning checks, not certified scores. Edited code is saved only with Save work and place. Run results are not stored as certified scores. Export useful unsaved work before leaving.
A short function primer before you begin
def names a reusable rule. The input names in parentheses are parameters. Indent its body; replace the starter's pass placeholder. The body runs when called, not when defined.
return hands a value back and ends that call. print only displays a value. The public assert checks call your function with fresh fixtures; a false condition raises AssertionError with its message.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Guided: return a lunch total
Package the multiplication rule so several inputs can be checked.
The contract
- Inputs price and people are nonnegative integers.
- Return their numeric product, not a display string or None.
- Zero people or a zero price gives zero; do not read interactive input or print as a substitute for returning.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Inspect 6 public checks
Transparent local learning checks, not exhaustive or tamper-proof grading.
- three lunches
assert lunch_total(8, 3) == 24, "Multiply price and people"
- different input
assert lunch_total(5, 2) == 10, "Use both supplied inputs"
- no people
assert lunch_total(8, 0) == 0, "Zero people cost zero"
- free price
assert lunch_total(0, 4) == 0, "A zero price gives zero"
- single lunch
assert lunch_total(9, 1) == 9, "One lunch keeps its price"
- numeric return
assert type(lunch_total(2, 4)) is int and lunch_total(2, 4) == 8, "Return an integer total"
Why are return and print different here?
return supplies a value the checks and other callers can use. print is only a visible effect. The rule uses one multiplication; integer operation cost still grows for arbitrarily large integers.
Guided: make a readable budget label
Return presentation text without losing the underlying numeric calculation.
The contract
- Inputs total and people are nonnegative integers.
- Return exactly 'Total: X for Y people', replacing X and Y with the supplied values.
- Do not print instead of returning or change the wording for zero/one in this deliberately fixed-format exercise.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Inspect 6 public checks
Transparent local learning checks, not exhaustive or tamper-proof grading.
- normal label
assert budget_label(24, 3) == "Total: 24 for 3 people", "Use the specified wording"
- zero total
assert budget_label(0, 2) == "Total: 0 for 2 people", "Keep a valid zero"
- zero people
assert budget_label(0, 0) == "Total: 0 for 0 people", "Use both zero inputs"
- one person fixed format
assert budget_label(9, 1) == "Total: 9 for 1 people", "Keep the exercise format"
- larger number
assert budget_label(120, 10) == "Total: 120 for 10 people", "Use the inputs"
- string result
assert isinstance(budget_label(8, 2), str) and budget_label(8, 2) == "Total: 8 for 2 people", "Return the label"
Why does exact output matter without implying this is the only good UI wording?
This exercise declares a fixed format so tests can check a precise contract. Other products may choose different wording; changing that is a requirement decision. Formatting work and output storage grow with the number of displayed characters.
Transfer: calculate the money left
Change the goal from computing cost to reporting signed remaining funds.
The contract
- Inputs budget, price and people are nonnegative integers.
- Return budget minus price multiplied by people.
- A negative result represents overspending and must not be silently clamped to zero.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Inspect 6 public checks
Transparent local learning checks, not exhaustive or tamper-proof grading.
- money left
assert remaining_budget(30, 8, 3) == 6, "Subtract the full cost"
- exact budget
assert remaining_budget(24, 8, 3) == 0, "Exact spending leaves zero"
- overspending
assert remaining_budget(20, 8, 3) == -4, "Keep a negative shortfall"
- no spending
assert remaining_budget(20, 8, 0) == 20, "No people means no spending"
- zero budget
assert remaining_budget(0, 5, 2) == -10, "An empty budget can be exceeded"
- return number
assert type(remaining_budget(9, 2, 2)) is int and remaining_budget(9, 2, 2) == 5, "Return the signed number"
What changed from lunch_total?
The cost calculation is reused, but the output meaning changed to remaining funds. A correct cost function is not itself a correct answer to this new requirement. The computation uses a fixed number of arithmetic operations, with integer cost dependent on magnitude.
Core route complete.
If you can explain the checkpoint and attempt the practice, move on. Come back for the deep dive when you want the why behind the how.
Save your core reading milestoneWhat actually runs?
Python checks source structure before executing it. A syntax error and an operation that fails during execution happen at different stages.
Understand first
Knowing which stage failed helps you decide whether to fix the spelling/structure of the program or trace the values reaching an operation.
Words you will see
- Syntax
- The grammar rules for valid source.
- Compile
- Translate valid source into an executable internal form.
- Runtime error
- An error raised while an executed operation is being performed.
Parsing is not execution
CPython parses source and compiles it into bytecode before executing that unit. An unmatched parenthesis or an invalid if statement can prevent any statements in that submitted script from running. Adding print before a syntax mistake does not make the earlier print a reliable checkpoint.
The example uses compile on trusted fixed lesson text so you can observe the distinction without submitting an invalid whole script. This is a demonstration of stages, not advice to evaluate arbitrary downloaded or user-supplied source.
A valid operation can still fail for its inputs
1 / 0 has valid syntax. It fails only when executed because division by zero is not defined here. A SyntaxError handler and a ZeroDivisionError handler identify different expected failures; neither should broadly hide every problem or substitute a reference answer.
Bytecode is an implementation detail, not a promise of direct machine-code performance. Other Python implementations can organise execution differently while preserving language behavior. For learners, the actionable distinction is whether the code was structurally valid and what operation failed.
The original example, step by step
These steps explain the original code below. They do not change when you edit your own experiment.
compile("value =", "example.py", "exec")An incomplete assignment is rejected before that source could run.
print("syntax stage")Name the caught syntax failure.
print(1 / 0)The division is valid source but fails before print receives a result.
print("execution stage")Name the expected runtime failure instead of pretending there is a number.
In CPython, source is parsed and compiled to bytecode, then executed by the interpreter. Syntax errors prevent that unit of code from running; runtime errors happen when an executed operation fails. Bytecode is an implementation detail, not a promise that Python behaves like machine code.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Change one thing; explain the difference.
Compile a complete assignment.
Try: Change "value =" to "value = 1".
The syntax-stage message disappears, because compiling that source now succeeds.
Repair the runtime input.
Try: Replace 1 / 0 with 1 / 2.
The run prints 0.5 instead of the execution-stage message.
Before you move on
Is dividing by zero a syntax mistake? Would a missing closing parenthesis be the same kind of failure?
Try explaining it in your own words. Running code is useful, but the explanation above gives you enough to reason it through first.
Read a worked answer
Division by zero is a runtime failure of a valid expression. A missing closing parenthesis makes the source invalid and can prevent the whole submitted unit from executing.
Reproducibility starts small
A reproducible example records the relevant environment and inputs, and avoids treating incidental machine details as the expected answer.
Understand first
A bug that only appears on a different interpreter or input cannot be investigated from an unexplained screenshot. Reproducible small programs provide evidence another person can check.
Words you will see
- Reproduce
- Run the relevant steps again with the same stated conditions.
- Deterministic output
- Output fixed by the stated inputs and behavior, not incidental ordering or timing.
- Compatibility
- Whether the environment supports the features the program requires.
Record useful facts without exposing unnecessary detail
Checking sys.version_info >= (3, 11) states a compatibility requirement without asserting one exact patch version. Sorting a set of names makes its display predictable while leaving the set itself unordered. These are deliberate assertions about behavior, not measured speed or machine addresses.
When reporting a problem, include the smallest relevant source, the inputs, the expected behavior and the actual error. Do not paste credentials, private paths or personal data merely to make a demonstration feel real.
Repeat the reason, not just the output
A deterministic sample still needs a reason for its expected output. Here there are two distinct names and sorting presents Ada before Lin. A successful output comparison does not prove that every possible input works or that you understand the method.
Change one input, predict the consequence, run and explain it. Re-run a fresh example rather than relying on invisible state from a previous experiment. Our isolated worker does that by design; downloaded scripts should document required setup and external resources.
The original example, step by step
These steps explain the original code below. They do not change when you edit your own experiment.
import sysUse a supplied standard-library module to inspect interpreter compatibility.
print(sys.version_info >= (3, 11))Display a supported-version comparison rather than one machine's full version string.
print(sorted(names))Create a sorted display list from unordered memberships.
Record your Python version, keep input explicit, and make output predictable. These examples target Python 3.11+ standard-library behaviour and need no third-party packages. Actual elapsed time, memory addresses and hash-order-dependent set displays are intentionally not expected outputs.
Run your edited Python in the browser, or download it. Ctrl/Cmd + Enter runs. One example runs at a time; each run starts fresh. Save work and place stores a private copy of edited code. Run results remain local learning feedback. No third-party execution service receives your code.
Preparing the editor controls. Run and editing become available when this page is interactive.
Browser Python limits
Python 3.13 with browser-compatible standard-library modules and prebundled SQLite, a 4-second execution limit, 16 KiB output and a 256 MiB Python heap cap. First loading can take up to 45 seconds. Total browser memory is browser-governed. No network, learner package installation, interactive input, host files or system processes. SQLite databases and temporary files disappear after each run. Platform-specific examples may report unsupported modules; download those for a suitable local environment.
Change one thing; explain the difference.
Add an earlier name.
Try: Add "Abe" to names.
The displayed list starts with Abe because sorting compares the names.
Separate display from storage.
Try: Print len(names) before and after sorted(names).
Both counts match; producing a display did not edit the set.
Before you move on
Does sorting a set for display make the underlying set ordered? Does one passing example prove the full rule?
Try explaining it in your own words. Running code is useful, but the explanation above gives you enough to reason it through first.
Read a worked answer
No to both. sorted returns a separate list; the set remains unordered. A passing example is evidence for that case, not exhaustive correctness or proof of understanding.
Make the explanation your own.
Use Save work and place to store notes with your code. Unsaved edits stay in this course tab; export before leaving. Reading milestones remain separate.
Take a versioned study copy
Export this lesson's original theory, textual model explanations, worked examples, public exercise checks and local-runtime boundaries for reading/review. This is separate from exporting your private workspace: no learner code, notes, identity, saved place or results are included. Offline server/browser execution is not provided.
Worked examples and explained concept checkpoints remain included. Reference answers for independent work are excluded unless you explicitly select them. A downloaded answer is not an earned pass.
Make this a milestone.
Save a self-reported core reading milestone and confidence. Confidence 1-3 schedules a review when none is already set; higher confidence does not create a new review. This is not a code execution pass or proof of mastery. Deep-dive reading is optional and is not tracked separately yet.