The Life Starter
0 of 6 complete0%
Course Library · Lesson 1 of 6
Digital · Guided lesson

Read values and predict a program

About 26 minutes · 6 reading + 20 practice and checks
Time includes reading, practice, and questions. Extra videos or further study are optional.
See this course’s project requirements

Build a supply-kit calculator, check it with five test cases, and explain how to use it. Combine the work you complete across the six lessons.

Keep your working files in your own notebook or software. Save a private description, checklist, and work link in My Proof.

What to include

  • State numeric input rules and invalid-input behavior.
  • Include a working function, conditional guard and loop over a list.
  • Show original, changed, empty and invalid-input reasoning.
  • Retain five explicit tests with expected results.
  • Provide complete code, expected output and a handoff note.

Review and revise

Use these criteria to check your work and choose what to improve.

  • Correctness: valid quantities produce independently checked kit counts.
  • Reasoning: traces explain assignment, branches and repeated work.
  • Testing: normal and invalid cases support the claimed behavior.
  • Handoff: supported inputs and limitations are clear.
Open the full course project
Want more background?
Before you begin

The idea in everyday life

A computer follows the instructions you actually wrote. Learning to predict a short program helps you distinguish your intention from its behavior. Our fictional community workshop packs supply kits. It needs no customer list or online account: quantities are invented, and every activity can be completed by tracing code on paper.

The idea

A variable is a name attached to the current value; assignment changes that attachment.

Try it

One step at a time.

Use the sample or information you have permission to use. Keep your work as you go. You can pause between steps.

  1. 1

    Create a page named kit-program. Record the task: find how many supplies remain after packing complete kits. Use whole-number counts so that negative or fractional inventory is visibly questionable.

  2. 2

    Copy the complete program in the example exactly. Read from the first line downward. For each assignment, evaluate the expression on the right before recording the value beside its name.

  3. 3

    Distinguish numbers from text: 12 can participate in arithmetic, while "12" is a string. Keep the output label in quotation marks and the computed value outside quotation marks.

  4. 4

    Predict the output without running anything. If an already available Python 3 environment is permitted, run the same code there; otherwise compare your trace with the worked result. Installation is optional.

  5. 5

    Set all three inputs for the second trace: supplies = 19, kits = 4, per_kit = 3. Run the remaining assignment again, then predict the printed output. This changes per_kit too; save both traces as the starting evidence for your final project.

Example

See how it works.

Fictional example: calculate the pencils remaining after packing workshop kits. Original input:

python
supplies = 23
kits = 5
per_kit = 4
remaining = supplies - kits * per_kit
print("Remaining:", remaining)

Multiplication happens before subtraction. The trace is supplies=23, kits=5, per_kit=4, remaining=3, and the output is Remaining: 3. Changed input: set all three values as shown, then run the complete program again.

python
supplies = 19
kits = 4
per_kit = 3
remaining = supplies - kits * per_kit
print("Remaining:", remaining)

The trace is supplies=19, kits=4, per_kit=3, remaining=7, and the output is Remaining: 7. Changing supplies or another input later does not automatically recalculate remaining: its assignment must execute again. The quoted label describes the number without changing its numeric type.

Check your work

Did you cover these?

  • Original trace: supplies=23, kits=5, per_kit=4, remaining=3.
  • Changed trace: supplies=19, kits=4, per_kit=3, remaining=7.
  • Output separates a quoted label from the number; both traces re-evaluate the remaining assignment.
Your work

What to finish

Two annotated traces and a saved copy of the program.

Common mistake

Watch for this

Assuming a previously calculated variable updates when an input changes.

How can I tell I understand it?

Explain each value and correctly trace the complete changed input set.

Try 3 questions

Quick knowledge check

Answer all 3 questions. Get at least 2 right and the lesson completes automatically.

Not yet passed

You’ll get an explanation for each answer. Signed in? Your results save to your account.

1A program sets stock=18, used=7, left=stock-used. What is left?
2You set x=4, y=x+2, then x=9. What is y?
3Which expression adds two numbers rather than joining text?
0 of 3 answeredApply the lesson to a short question, then review the explanation.
1
Finish this lesson

Pass the check. We’ll save the progress.

Answer all 3 questions above and get at least 2 right. You can review the explanations and try again.

Go to the knowledge check
Tools, templates, and lesson sources

Tools and templates

Tools open in a new tab so you can keep your place here.

Sources and further reading

Explore the references behind this lesson.

Harvard CS50 — Introduction to Programming with Python
Source & access notes · checked 2026-09-10

Opened the course overview and Week 0 page; verified coverage of variables, conditionals, loops, exceptions and testing. Optional deeper study, not a source of copied exercises.

Access: OpenCourseWare is free to read/watch. External assignment submission requires an edX account; optional verified/professional certificates use separate enrollment and may cost money. No Harvard affiliation or credit is offered here.

Reuse: Linked for reference. Examples, activities and assessments here are original; free access alone does not grant permission to reuse source text or branding.

Python documentation — An Informal Introduction
Source & access notes · checked 2026-09-10

Opened official Python 3 tutorial; read arithmetic, assignment, strings, lists and indexing sections.

Access: Free public reading; no account or certificate is required for this Life Starter course.

Reuse: Linked for reference. Examples, activities and assessments here are original; free access alone does not grant permission to reuse source text or branding.

Report a problem with this lesson

Tell us what went wrong. Please leave out personal information and private project contents.

No sign-in needed.