Make a decision with a condition
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.
Want more background?
The idea in everyday life
Supply counts can exceed the amount available. A useful program must say what happens in that case instead of silently reporting a misleading plan. Conditions let one set of instructions handle several situations. You will write a rule for fictional kits and test values below, exactly at, and above its threshold.
A condition chooses a branch; equality belongs to whichever branch you specify.
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
Write the rule in ordinary language: pack only when available supplies are at least the requested amount. State that equality is acceptable, because having exactly enough supplies still permits packing.
- 2
Compute needed as kits multiplied by per_kit. Compare supplies with needed using >=. Read this symbol aloud as greater than or equal to, and distinguish comparison from assignment with =.
- 3
Copy the if and else structure in the example. Indent each branch by four spaces. Only the branch chosen by the condition runs for that input.
- 4
Make a three-row test table with supplies of 11, 12 and 13, keeping needed at 12. Predict both the message and remainder before an optional run.
- 5
Add a written input rule that kit quantities must be nonnegative whole numbers. This lesson does not validate every possible type; save that limitation alongside the branch tests for later refinement.
See how it works.
Fictional example: four kits need three pencils each. This program protects the packing decision:
supplies = 12
kits = 4
per_kit = 3
needed = kits * per_kit
if supplies >= needed:
print("Pack", kits, "kits")
else:
print("Need", needed - supplies, "more")At 12 supplies it prints Pack 4 kits; equality is included. With supplies=11 it prints Need 1 more. With supplies=13 it still packs four kits, leaving one supply unused. The condition does not increase the requested number of kits automatically. Requirements decide the intended behavior, while the comparison implements that requirement.
Did you cover these?
- 11 produces a shortage of 1.
- 12 follows the packing branch.
- Both branch bodies are indented consistently.
What to finish
A conditional program and a three-row threshold test table.
Watch for this
Using > when the requirement includes exactly enough.
How can I tell I understand it?
Predict both branches and justify the equality case.
Quick knowledge check
Answer all 3 questions. Get at least 2 right and the lesson completes automatically.
You’ll get an explanation for each answer. Signed in? Your results save to your account.
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 checkTools, 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.
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.
Source & access notes · checked 2026-09-10
Opened official tutorial covering if, for, range and function definitions; examples use stable Python 3 syntax.
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.