CSC 141 · PA1
A guided Python workbook / Assignment 1

From a blank file
to “it works.”

Learn where to click, what to type, and how to check each small step. Then turn four worked practice problems into the confidence to start your own.

Beginner friendlyWindows + macOS6 guided animations4 complete practice variants
Start with your setup →
01 / Start here

You do not have to write the whole program at once.

Your first goal is small: create one file, run one line, and see one result. Then build each program in pieces you can check.

ReadPlanWrite a littleRun & check

This workbook accompanies CSC 141 · Programming Assignment 1, covering variables, types, expressions, and formatted output. You can stop after any checkpoint and return later. Your checkmarks are saved in this browser when browser storage is available.

A manageable first session

Complete sections 2 and 3. When your screen prints a greeting and accepts a name, you have learned the complete edit → save → run cycle. That is a successful first session.

What belongs where?

PartWhat you makeWhere this guide helps
A · 20 pointspartA.txtPrediction, tracing, and error-reading method
B · 10 pointsComments inside bill_split.pyWrite a plan before the receipt code
C · 60 pointsFour separate .py programsProgram 1 planning; complete variants for Programs 2–4
D · 10 pointsdebug_me.pyA fully explained debugging variant

The handout is the specification. Its due date is September 17, 2026 at 11:59 PM (extended); check D2L for any update. This guide teaches related practice problems. Write and explain your own homework programs, following the assignment’s collaboration and AI rules. The practice files are not submission files.

Open the assignment handout ↗ · Open the course Python Playground ↗

02 / Prepare your computer

Install the three pieces you need.

VS Code is where you edit files. Python 3 executes the instructions. The Microsoft Python extension connects them. Installing the extension alone does not install Python.

Windows setup

  1. Visit python.org/downloads and get the official Python Install Manager for Windows. Open the downloaded installer and select Install. If Python 3 already works on your computer, you can keep it.
  2. Open the Windows Start menu, type PowerShell, and open it. Type python --version and press Enter. On a new Install Manager installation, the first launch may install the default stable runtime. Allow it to finish. You want a response starting with Python 3.. If needed with the new manager, run py install default, then repeat the version check. An older working launcher may instead accept py -3 --version.
  3. Download Visual Studio Code for Windows. Open the installer and follow its prompts. Open Visual Studio Code from Start. The full Visual Studio product is a different application.
  4. In VS Code, click the Extensions icon on the left (four squares), search Python, and install the extension published by Microsoft. Restart VS Code after installing Python so it can detect the interpreter.

If an older Python installer shows “Add Python to PATH,” enabling it makes terminal commands easier to find. Current Install Manager screens differ; use the official Windows instructions linked below if your screen differs. Do not uninstall a working Python setup just to match a screenshot.

Select the Python interpreter in VS Code

  1. Open the Command Palette: Ctrl Shift P on Windows or ⌘ Shift P on macOS.
  2. Type Python: Select Interpreter and select that command. Choose your installed Python 3.x. “Interpreter” means the Python program that will run your code.
  3. If no interpreter appears, finish installing Python, fully close and reopen VS Code, and try again. If the command itself is missing, check that the Microsoft Python extension is installed and enabled.

Setup references: Python on Windows, Python on macOS, Python in VS Code, VS Code on macOS. Menus can vary slightly by version.

03 / Your first successful run

Create → type → save → run.

Create an organized place for your work

  1. Open File Explorer (Windows) or Finder (Mac). Inside Documents, create a folder named CSC141_PA1. On Windows, right-click an empty area and choose New → Folder. On Mac, choose File → New Folder.
  2. Inside it, create two folders: practice and submission. Practice examples go in practice; your six original homework files go in submission.
  3. In VS Code, select File → Open Folder… and choose CSC141_PA1. If asked about workspace trust, trust this folder if it is the folder you just created.
  4. Open Explorer in VS Code (the file icon on the left). Right-click the practice folder, select New File, type hello_practice.py, and press Enter. The .py ending tells the editor this is Python.
CSC141_PA1/
    practice/
        hello_practice.py
    submission/
        (your original homework files will go here)

Type these two lines in the editor

print("Hello, CSC 141!")
print(2 + 3)
  1. Click the large editor area beside line 1 and type the code above. Use straight quotes ", not curly word-processor quotes. Do not type the line numbers or Markdown backticks.
  2. Save with Ctrl S (Windows) or ⌘ S (Mac). If Save As appears, select your practice folder and use the exact name hello_practice.py. The unsaved dot on the tab should disappear.
  3. With hello_practice.py as the active tab, select the top-right Run Python File triangle. If needed, use its dropdown or right-click the editor and select Run Python → Run Python File in Terminal. Use the Python extension’s command.
  4. Look in the Terminal panel at the bottom. It may first show a long command containing your Python and file paths. Below that command, look for the two lines shown next.
Hello, CSC 141!
5

Now make Python ask you a question

Replace the file’s contents with these two lines, save, and run again:

name = input("Your name: ")
print(f"Hello, {name}!")

When Your name: appears, click inside the terminal, type Jordan without quotes, and press Enter. Python then prints Hello, Jordan!. The waiting cursor is normal: your program is waiting for input.

You type…Where?Why?
name = input(...)Editor, inside the .py fileIt is an instruction to save and execute.
JordanTerminal, after the running program’s promptIt is data your program requested.
python3 hello_practice.pyTerminal, at the shell promptIt is an optional command to launch a file, not Python source.
Optional: run a file by typing a terminal command

Right-click the practice folder in VS Code Explorer and choose Open in Integrated Terminal. Run python hello_practice.py on Windows (or py hello_practice.py if that is your working launcher); run python3 hello_practice.py on macOS. The terminal must be in the folder containing the file. If you see >>>, you are inside Python’s interactive prompt: type exit() first. The Run Python File button handles paths for you and is the easier first option.

04 / A small toolkit

Understand one line before adding the next.

All practice programs here use straight-line code. You do not need loops, conditionals, classes, or external packages for these exercises. Assume valid inputs as the assignment specifies.

ToolExampleWhat it means
Text / str"12"Characters. Quotation marks in source code mark text.
Whole number / int12A number with no fractional part.
Decimal number / float12.0A numeric value that can have a fractional part.
Assignmentcount = 3Compute the right side, then store the result under the name on the left.
Read and convertcount = int(input("Count: "))Read text, convert it to a whole number, and store it.
True division9 / 2Produces 4.5.
Whole quotient and remainder9 // 2 and 9 % 2Produce 4 and 1 for these positive inputs.
Power3 ** 2Produces 9.
Formatted outputf"Cost: ${amount:.2f}"Inserts amount as text with two decimal places.

Your reusable “I don’t know how to start” routine

  1. Underline the information the user must type. Give each item a descriptive snake_case name and decide whether it is text, int, or float.
  2. Write down the required outputs. Next to each one, do a tiny example on paper with easy numbers.
  3. Write comment lines beginning with # that describe the steps in English. Put a calculation after the inputs it needs.
  4. Implement only the input lines. Save and run. Add a temporary print to check the inputs if useful.
  5. Add one calculation. Print its value and compare it to your paper calculation. Repeat for the remaining calculations.
  6. Replace temporary checking prints with the required formatted output. Save and test with more than one set of inputs.

Use a header in every homework Python file

# CSC 141 - Programming Assignment 1 - <file name>
# Name: <your full name>
# Date: <the date you finish>
# Description: <one or two sentences describing this program>

Replace the angle-bracket placeholders with your own information. Comments are for people; Python skips them. In these exercises, start normal statements at the left edge. Accidental spaces at the start can cause an unexpected-indentation error.

05 / Part A and Program 1

Practice reasoning before looking at output.

Part A: create a plain-text answer file

Right-click submission → New File → partA.txt. Save your answers as plain text in VS Code. This is a written-answer file, not a Python program, so do not run it with the Python button.

  1. For A1, copy each expression from the handout into your answer file. Write your predicted value and type before running anything.
  2. Create a separate practice Python file to verify expressions. For a different example, use the code below. A string’s quote marks may disappear when printed, so inspect type() as well.
  3. Keep your first prediction. If it was wrong, add the actual result and one sentence explaining the difference.
  4. For A2, draw a table with one row per assignment. Update only the variables changed by that line. For a simultaneous swap, read both old right-hand values before updating either name. Then inspect sep and end in each print call to reconstruct spaces and line breaks.
  5. For A3, run the handout’s short program in a practice file. Copy the exact last line of the traceback into partA.txt, explain the types involved, and write your fix. A traceback is Python’s description of where execution failed.
sample = 23 // 4
print(sample)
print(type(sample))

For this different example, predict a whole quotient of 5 and type int. Python prints 5 and <class 'int'>.

A1 — expression: [copy from the handout]
My prediction — value: ...   type: ...
Observed — value: ...        type: ...
Explanation if my prediction changed: ...

A2 — trace table and exact printed output:
...

A3 — exact last error line:
...
Why it happens:
...
My correction:
...

Program 1: time_convert.py — a planning checkpoint

This section intentionally provides a plan, not a complete worked solution. Create time_convert.py in submission, add your header, and open the original problem next to it.

  1. Identify the input: a whole number of seconds. List the two requested output lines before coding.
  2. On paper, draw boxes for complete hours, leftover seconds, complete minutes in that leftover amount, and final seconds. The handout gives the seconds-per-hour conversion.
  3. Ask yourself: which operator counts complete groups, and which keeps what did not fit? Use the // and % examples in the toolkit. The number of minutes within the hour differs from the total minutes in the original duration.
  4. Write comments describing your sequence, then implement one calculation at a time. Use temporary prints to inspect intermediate quantities.
  5. Check the original samples. Also try zero, exactly one minute, and exactly one hour. Do the leftover seconds and within-hour minutes stay between 0 and 59? Format the total-minutes line to two decimal places and remove temporary prints.
06 / Worked variant

Share the cost of a picnic

Program 2 · bill_split.py + Part B

Three friends buy picnic supplies. A delivery fee is a percentage of the supplies cost. Find the fee, the final cost, and the equal share. This practices the same percentage → total → share sequence as the receipt assignment.

01

Plan in English before Python

These comments are pseudocode: a recipe for the program, not commands Python executes. Notice that every input, calculation, and output has a place. For Part B, write your own recipe directly below the header in bill_split.py.

# Ask for the supplies cost.
# Ask for the delivery percentage.
# Ask for the number of friends.
# Convert the percentage to a decimal and calculate the fee.
# Add the fee to the supplies cost.
# Divide the total by the number of friends.
# Print a title, aligned costs, the percentage label, and border lines.
02

Read three inputs and convert them

input() pauses and returns text. float() converts a decimal amount such as "48" into 48.0; int() converts a whole-number count such as "3" into 3. Run these three lines now. Enter 48, then 12.5, then 3, pressing Enter after each. No receipt yet is expected.

supplies_cost = float(input("Supplies cost ($): "))
delivery_percent = float(input("Delivery percent: "))
friends = int(input("Number of friends: "))
03

Calculate in dependency order

Do the same math on paper first: 12.5 / 100 = 0.125; 48 × 0.125 = 6; 48 + 6 = 54; 54 / 3 = 18. Each line uses values already available. Temporarily add print(delivery_fee, total_cost, cost_per_friend) to check 6.0 54.0 18.0, then remove that temporary line.

delivery_fee = supplies_cost * (delivery_percent / 100)
total_cost = supplies_cost + delivery_fee
cost_per_friend = total_cost / friends
04

Print a readable receipt

print() makes a blank line. "=" * 25 builds a line from one character. The f before the quote allows {expressions}. In :>10.2f, > means right-align, 10 is the minimum field width, and .2f displays exactly two decimal places. The label field :<17 is left-aligned. Width is a minimum, not a limit; an unusually long label can move its column. .1f displays 12.5 in the fee label.

print()
print("PICNIC COSTS")
print("=" * 25)
print(f"{'Supplies:':<17}${supplies_cost:>10.2f}")
fee_label = f"Delivery ({delivery_percent:.1f}%):"
print(f"{fee_label:<17}${delivery_fee:>10.2f}")
print(f"{'Total:':<17}${total_cost:>10.2f}")
print("-" * 25)
print(f"{'Each friend:':<17}${cost_per_friend:>10.2f}")
print("=" * 25)

Run it with these inputs

Type each line below when its prompt appears in the terminal. Press Enter after every input. Do not type quotation marks or slash separators.

48
12.5
3

Expected terminal output

The real terminal shows each value you type next to its prompt. The transcript below includes those typed values.

Supplies cost ($): 48
Delivery percent: 12.5
Number of friends: 3

PICNIC COSTS
=========================
Supplies:        $     48.00
Delivery (12.5%):$      6.00
Total:           $     54.00
-------------------------
Each friend:     $     18.00
=========================
Reveal the complete practice file

Use this to check your work after building the pieces. Explain each line, then close it and solve the homework version independently.

# CSC 141 - PA1 companion practice - practice_picnic.py
# Name: Practice example
# Date: 2026-09-07
# Description: Instructor-provided variant for practice; not a PA1 submission.

# Ask for the supplies cost.
# Ask for the delivery percentage.
# Ask for the number of friends.
# Convert the percentage to a decimal and calculate the fee.
# Add the fee to the supplies cost.
# Divide the total by the number of friends.
# Print a title, aligned costs, the percentage label, and border lines.

supplies_cost = float(input("Supplies cost ($): "))
delivery_percent = float(input("Delivery percent: "))
friends = int(input("Number of friends: "))

delivery_fee = supplies_cost * (delivery_percent / 100)
total_cost = supplies_cost + delivery_fee
cost_per_friend = total_cost / friends

print()
print("PICNIC COSTS")
print("=" * 25)
print(f"{'Supplies:':<17}${supplies_cost:>10.2f}")
fee_label = f"Delivery ({delivery_percent:.1f}%):"
print(f"{fee_label:<17}${delivery_fee:>10.2f}")
print(f"{'Total:':<17}${total_cost:>10.2f}")
print("-" * 25)
print(f"{'Each friend:':<17}${cost_per_friend:>10.2f}")
print("=" * 25)

Test more than the first example

Run the file again for each row. Slashes below separate inputs; type them one at a time, without slashes.

Inputs, in prompt orderExpected checks
48 / 12.5 / 3Fee $6.00; total $54.00; share $18.00
80 / 0 / 4Fee $0.00; total $80.00; share $20.00
10 / 7.5 / 3Fee $0.75; total $10.75; share $3.58

Now transfer the idea to your homework

  1. Create bill_split.py in your submission folder and write its header and your Part B pseudocode first.
  2. Translate supplies → bill, delivery percentage → tip percentage, friends → people. Re-read the original prompts and receipt labels; changing only the practice filename is not enough.
  3. Compute the percentage amount, then total, then share. Keep full values during calculations; format only when printing.
  4. Include the entered tip percentage in the Tip label using an f-string. Build the required 25-character lines using string repetition. Compare spacing and two-decimal output against the handout.
  5. Run the original sample, then invent a zero-tip case and a case whose share needs rounding. Explain why dividing the percent by 100 is necessary.
07 / Worked variant

Build a club membership badge

Program 3 · name_tag.py

A club badge shows a member’s full name, whole years since joining, and an approximate number of months. The border must grow when the name grows. This variant uses a joining year, not a birth year.

01

Name the fixed value, then read the changing values

A constant is a value we intend to keep fixed; uppercase is our naming convention. Names stay as strings. Convert only the year because subtraction requires a number. Assume the membership anniversary already happened this year.

CURRENT_YEAR = 2026

first_name = input("First name: ")
last_name = input("Last name: ")
join_year = int(input("Year joined: "))
02

Build the name and calculate facts

The quoted space matters. "Maya" + " " + "Chen" is "Maya Chen", with 9 characters including the space. 2026 − 2022 = 4 years; 4 × 12 = 48 months. len() counts characters, including spaces.

full_name = first_name + " " + last_name
name_length = len(full_name)
years_member = CURRENT_YEAR - join_year
approx_months = years_member * 12
03

Make the border fit the content

The content row has four extra characters: left #, left space, right space, right #. Therefore the border length is 9 + 4 = 13. Do not hard-code 13: another name needs a different width. Parentheses make the entire length the repetition count.

border = "#" * (name_length + 4)
print()
print(border)
print(f"# {full_name} #")
print(border)
04

Align the facts and repeat the first name

The label field :<17 gives the labels the same minimum width. Spaces between the three expressions keep the repeated names separate. First check the facts; then check alignment. You do not need loops to print three names.

print(f"{'Name length:':<17}{name_length} characters")
print(f"{'Years in club:':<17}{years_member}")
print(f"{'Approx. months:':<17}{approx_months}")
print(f"{'Name cheer:':<17}{first_name} {first_name} {first_name}")

Run it with these inputs

Type each line below when its prompt appears in the terminal. Press Enter after every input. Do not type quotation marks or slash separators.

Maya
Chen
2022

Expected terminal output

The real terminal shows each value you type next to its prompt. The transcript below includes those typed values.

First name: Maya
Last name: Chen
Year joined: 2022

#############
# Maya Chen #
#############
Name length:     9 characters
Years in club:   4
Approx. months:  48
Name cheer:      Maya Maya Maya
Reveal the complete practice file

Use this to check your work after building the pieces. Explain each line, then close it and solve the homework version independently.

# CSC 141 - PA1 companion practice - practice_badge.py
# Name: Practice example
# Date: 2026-09-07
# Description: Instructor-provided variant for practice; not a PA1 submission.

CURRENT_YEAR = 2026

first_name = input("First name: ")
last_name = input("Last name: ")
join_year = int(input("Year joined: "))

full_name = first_name + " " + last_name
name_length = len(full_name)
years_member = CURRENT_YEAR - join_year
approx_months = years_member * 12

border = "#" * (name_length + 4)
print()
print(border)
print(f"# {full_name} #")
print(border)

print(f"{'Name length:':<17}{name_length} characters")
print(f"{'Years in club:':<17}{years_member}")
print(f"{'Approx. months:':<17}{approx_months}")
print(f"{'Name cheer:':<17}{first_name} {first_name} {first_name}")

Test more than the first example

Run the file again for each row. Slashes below separate inputs; type them one at a time, without slashes.

Inputs, in prompt orderExpected checks
Maya / Chen / 202213 border characters; 4 years; 48 months
Al / Li / 20269 border characters; 0 years; 0 months
Alexandra / Rivera / 202020 border characters; 6 years; 72 months

Now transfer the idea to your homework

  1. In name_tag.py, the third input is a birth year. Use CURRENT_YEAR = 2026 and the assignment’s assumption about birthdays.
  2. Calculate age and approximate days using the factors specified in the handout; the practice membership/month calculations are different.
  3. Change the badge border to the required asterisks. Count all four outside characters and derive width from len(full_name).
  4. Print the original required labels, the name length, age, approximate days, and three first names. Match the columns.
  5. Test both short and long names. If you can explain why the border needs +4, you are ready to build your own box.
08 / Worked variant

Calculate a robot’s motion

Program 4 · free_fall.py

A robot starts from rest and accelerates constantly at 2.5 meters per second squared along a straight track. Given the distance, calculate the travel time and final speed. The arithmetic structure matches the free-fall problem, but the physical situation and constant differ.

01

Translate the quantities and units

Use a nonnegative distance. ACCELERATION is measured in m/s². distance is measured in meters and can contain a decimal point. The robot starts with zero speed; this model does not describe a robot moving at a constant speed.

ACCELERATION = 2.5
distance = float(input("Track distance in meters: "))
02

Translate the whole square root

The formula is t = √(2d/a). First compute 2 × 20 / 2.5 = 16; then 16 ** 0.5 = 4 seconds. Parentheses put the whole fraction under the square root. ** is exponentiation. ^ is not the Python exponent operator.

travel_time = (2 * distance / ACCELERATION) ** 0.5
03

Use time to compute speed, then convert units

At the end of 4 seconds, speed is 2.5 × 4 = 10 m/s. Convert m/s to km/h by multiplying by 3.6, giving 36 km/h. This is final speed, not average speed. Store the unrounded time for later calculations.

final_speed = ACCELERATION * travel_time
final_speed_kmh = final_speed * 3.6
04

Display results with units

The units in the quotes are just text labels, but they make each result meaningful. .2f prints 4.00 rather than 4.0. Do not round travel_time before using it to compute final_speed.

print(f"Travel time: {travel_time:.2f} s")
print(f"Final speed: {final_speed:.2f} m/s ({final_speed_kmh:.2f} km/h)")

Run it with these inputs

Type each line below when its prompt appears in the terminal. Press Enter after every input. Do not type quotation marks or slash separators.

20

Expected terminal output

The real terminal shows each value you type next to its prompt. The transcript below includes those typed values.

Track distance in meters: 20
Travel time: 4.00 s
Final speed: 10.00 m/s (36.00 km/h)
Reveal the complete practice file

Use this to check your work after building the pieces. Explain each line, then close it and solve the homework version independently.

# CSC 141 - PA1 companion practice - practice_robot.py
# Name: Practice example
# Date: 2026-09-07
# Description: Instructor-provided variant for practice; not a PA1 submission.

ACCELERATION = 2.5
distance = float(input("Track distance in meters: "))

travel_time = (2 * distance / ACCELERATION) ** 0.5

final_speed = ACCELERATION * travel_time
final_speed_kmh = final_speed * 3.6

print(f"Travel time: {travel_time:.2f} s")
print(f"Final speed: {final_speed:.2f} m/s ({final_speed_kmh:.2f} km/h)")

Test more than the first example

Run the file again for each row. Slashes below separate inputs; type them one at a time, without slashes.

Inputs, in prompt orderExpected checks
20Time 4.00 s; speed 10.00 m/s; 36.00 km/h
5Time 2.00 s; speed 5.00 m/s; 18.00 km/h
0Time 0.00 s; speed 0.00 m/s; 0.00 km/h

Now transfer the idea to your homework

  1. Create free_fall.py, write the required header, and list its one input and three outputs.
  2. Use the handout’s gravity constant and drop-height interpretation. Rewrite the formula from the handout with Python multiplication, division, parentheses, and ** 0.5.
  3. Compute fall time before impact speed, then convert that speed to km/h.
  4. Use the original prompts and labels with units and two decimal places. Keep the underlying values unrounded.
  5. Check the handout sample and height zero. Increasing the height should increase both time and speed. Explain exactly which expression lies under the square root.
09 / Worked variant

Repair a locker-rental calculator

Part D · debug_me.py

A locker rental has a unit price, a quantity, and an 8% service fee. First predict what the broken code does. Then repair one issue at a time. A program can finish without an exception and still produce a completely wrong answer.

First inspect the broken listing

Line numbers below are reference labels; do not type them into your file. Trace with price 7.5 and quantity 4 before opening the repairs.

 1  # Locker rentals with an 8% service fee.
 2  unit_price = input("Locker price ($): ")
 3  quantity = int(input("Number of lockers: "))
 4  subtotal = unit_price * quantity
 5  service_fee = subtotal * 8
 6  total = subtotal + service_fee
 7  print("Total: " + total)
01

Repair the numeric input

The original input is text. For input 7.5 and 4, text "7.5" * 4 repeats characters; numeric 7.5 * 4 computes 30.0. The fix belongs where the price is read. quantity is already converted correctly.

unit_price = float(input("Locker price ($): "))
quantity = int(input("Number of lockers: "))
subtotal = unit_price * quantity
02

Repair the percentage

8% means 8 / 100 = 0.08, not 8. The correct fee is 30 × 0.08 = 2.4; the total is 32.4. A wrong percentage is a logic error: Python can do that wrong calculation perfectly without warning you.

SERVICE_RATE = 0.08
service_fee = subtotal * SERVICE_RATE
total = subtotal + service_fee
03

Repair the final output and document the changes

Once total is a float, "Total: " + total cannot concatenate text and a number. The f-string inserts the number and formats money. Write bug comments referencing the original broken listing’s line numbers, not the shifted lines in the repaired file.

print(f"Total: ${total:.2f}")

Run it with these inputs

Type each line below when its prompt appears in the terminal. Press Enter after every input. Do not type quotation marks or slash separators.

7.5
4

Expected terminal output

The real terminal shows each value you type next to its prompt. The transcript below includes those typed values.

Locker price ($): 7.5
Number of lockers: 4
Total: $32.40
Reveal the complete practice file

Use this to check your work after building the pieces. Explain each line, then close it and solve the homework version independently.

# CSC 141 - PA1 companion practice - practice_locker_debug.py
# Name: Practice example
# Date: 2026-09-07
# Description: Instructor-provided variant for practice; not a PA1 submission.

# Bugs in the ORIGINAL numbered locker listing below:
# Line 2: input returned text; convert unit_price with float().
# Line 5: multiplier 8 means 800%; use 0.08 for an 8% fee.
# Line 7: text + numeric total fails after input is fixed; use an f-string.

unit_price = float(input("Locker price ($): "))
quantity = int(input("Number of lockers: "))
subtotal = unit_price * quantity

SERVICE_RATE = 0.08
service_fee = subtotal * SERVICE_RATE
total = subtotal + service_fee

print(f"Total: ${total:.2f}")

Test more than the first example

Run the file again for each row. Slashes below separate inputs; type them one at a time, without slashes.

Inputs, in prompt orderExpected checks
7.5 / 4Subtotal $30.00; fee $2.40; printed total $32.40
10 / 1Subtotal $10.00; fee $0.80; printed total $10.80
0 / 3Subtotal $0.00; fee $0.00; printed total $0.00

Now transfer the idea to your homework

  1. Copy the Part D starter from your handout into debug_me.py. Do not copy this locker example into that file.
  2. Before running, trace the original assignment inputs by hand. Track both the value and type after every assignment.
  3. Identify the same three categories: unconverted price input, incorrect percent multiplier, and output that must safely format a numeric total. Use the original assignment’s tax rate.
  4. Add comments listing each original line number, the bug, and your fix. Keep your normal assignment header too.
  5. Test the exact original sample and an additional valid input pair. Do not stop at “there was no error”: compare the money result to hand arithmetic.
10 / When something goes wrong

Use the symptom to choose your next step.

An error message is information about a particular step. Read the last error line first, then the file name and line number above it. Change one thing, save, and run again.

What you seeWhat it usually meansTry this
Python: Select Interpreter is missingThe Python extension is unavailable or disabled.Install or enable the Microsoft Python extension, then reopen VS Code.
No Python interpreter / command not foundPython is missing or the app has not detected it.Verify installation using the OS steps; reopen VS Code and select Python 3.
Cannot edit in read-only editorYou may be typing input in Output, not Terminal.Run Python File in Terminal; click Terminal and type after the program prompt.
A prompt and a blinking cursor; no final outputinput() is waiting for you.Type one requested value and press Enter. Repeat for each prompt.
ValueError when converting inputThe text does not match the conversion.For float, type 7.5, not $7.50. For int, type 3, not 3.0. Do not include commas, %, or quotes.
TypeError involving str and a numberText and numeric data were mixed incorrectly.Check input conversion and use an f-string to insert a number into output.
SyntaxErrorPython cannot read the instruction as written.Check matching quotes and parentheses on that line and the previous line. Use plain quotes.
NameErrorA name has not been defined with that spelling.Match spelling and capitalization exactly; define the variable before using it.
IndentationErrorA statement has unexpected leading spaces.For these straight-line examples, put statements at the left edge.
Old results after editingYou may be running an unsaved or different file.Save, select the intended .py tab, and check the path shown in the terminal command.
No such file / cannot open fileThe terminal command points to the wrong folder or filename.Use Run Python File from the correct open tab, or open a terminal in the file’s folder.
The file is named program.py.txtIt is still a text file with an extra extension.Show filename extensions in your file manager and rename it to end only in .py. VS Code Explorer also shows the filename.
Numbers run together or repeatA numeric input may still be a string.Print type(your_variable) temporarily; convert it before doing arithmetic.
The program runs, but the answer is wrongThis may be a logic error.Use easy inputs and inspect each intermediate value. Check percent / 100 and formula parentheses.

A useful office-hours question

Bring your laptop, the .py file, the input you tried, the expected result, and the actual output or last error line. A specific starting point is enough:

“I can read the three inputs. With these values, I expected the fee to be 6, but it prints repeated text. This is the line I think is involved.”

If you are overwhelmed, pause after one successful checkpoint. You can ask for help before a whole program is finished.

11 / Finish and submit

Check the files, then check the ZIP.

Finish your original programs in submission. Keep the practice solutions elsewhere. Part B is included as comments in bill_split.py, so there is no separate Part B file.

submission/
    partA.txt
    time_convert.py
    bill_split.py
    name_tag.py
    free_fall.py
    debug_me.py
  1. Save every file. Check that the five Python files have your required header, bill_split.py has your pseudocode, and debug_me.py has your bug list with original line numbers and fixes.
  2. Run each .py file separately. Compare against the handout sample, then a second valid case. Remove temporary debugging prints. Open partA.txt and check predictions, types, the trace, and your error explanation.
  3. In File Explorer or Finder, open the submission folder. Select exactly the six listed files. On Windows, right-click → Compress to ZIP file (or Send to → Compressed (zipped) folder on older menus). On Mac, right-click → Compress 6 Items.
  4. Rename the archive Lastname_Firstname_PA1.zip, using your actual last and first names. Avoid accidentally adding a second .zip extension.
  5. Open the ZIP and verify that all six files are present, with the correct extensions. Do not include practice files, screenshots, PDFs, or the guide. If you change a file after making the ZIP, rebuild the ZIP so it contains the updated version.
  6. Open D2L → this course → the Programming Assignment 1 submission area. Upload the ZIP and complete the submission action shown there. Check for confirmation and the uploaded filename. D2L controls the current deadline and submission status.

Keep the practice workbook

This page’s lessons, animations, and practice downloads work without a server. External installation links and the course Playground need internet access.

The ZIP contains only practice variants and a README, not homework answers. Printing expands the worked solutions and animation transcripts.