FreeCampus Python

Milestone Challenge: Pack a Moon-Garden Supply Box

Write and explain a dispatch-card program using names, integer arithmetic, conversion, and formatting.
Open in Colab
  • Goal: Write and explain a dispatch-card program using names, integer arithmetic, conversion, and formatting.
  • Estimated time: 2–4 hours of active work.
  • Before starting: Complete the milestone units and their unit challenges.
  • Keep: Your source, observed outputs, checks, and a debugging note.

This community challenge is ungraded. Use the checks to review your own work; there is no submission service or automatic grade. Completion is self-reported in this browser on this device.

1. Pack a moon-garden supply box

The box holds 17 seed packets. Each packet costs 125 cents and delivery costs 350 cents per box. Store these as named integers, calculate the subtotal and total, and print the garden name, packet count, and total in dollars with two decimal places. Calculate in cents until display. Use straight-line statements; loops, functions, and collections are not needed yet.

Predict an ordinary result before coding. Start with the smallest part you can run and inspect. Use Colab for notebooks and the local workspace introduced in the units for packaging or command-line tasks.

2. Set up the experiment

garden = "Moon Garden"
packets = 17
cents_per_packet = 125
delivery_cents = 350
# Calculate the subtotal and total, then print the dispatch card.

The starter is deliberately incomplete. Implement the contract; do not change the expected results to match an incorrect implementation.

3. Check the observable results

  1. The packet subtotal is 2,125 cents and the total is 2,475 cents ($24.75).
  2. With zero packets the delivery charge still applies: $3.50.
  3. With free delivery the original order costs $21.25.
  4. Restart the notebook and run from the top without relying on earlier experiments.

Record actual outputs beside predictions. Reduce a failure to a small example, change one cause at a time, and repeat the failed check after repairing it.

4. Change one condition

A helper provides a delivery price as the text “425”. Convert it explicitly, explain the types before and after conversion, and recalculate the original order: $25.50. Do not add validation or exception handling yet.

5. Review a hint after attempting the task

Hint: connect the relevant tools

Multiply packets by cents_per_packet, then add delivery_cents. Divide by 100 only for display and use a two-decimal format specification.

6. Explain and self-review

Keep a hand calculation, the printed card, and an annotated source listing. Explain one assignment, expression, and formatting choice. Record one syntax error you repaired and how you located it.

Review path: compare your result with the contract

Check the ordinary result first, then the boundary cases and changed condition. Explain which rule justifies each result. An implementation that differs from the hint can still satisfy the contract; explain why yours does.

7. Save your work and record completion

Save the notebook or project somewhere you control. Include one decision, one failed check, its repair, and a result you can reproduce. Record completion after reviewing the checks; you can undo it later.

Not yet recorded.

Return to the milestone overview.

Back to top