thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

06.03 · Function challenges / Watch · 7 min

Trace the calculation back to the caller

For dog age 5, the calculation moves through 3 to 33, then returns 33 to the caller.

Activity 3 of 4 in Function challenges

All courses

Python 2: Logic, Loops & Functions / 06.03

Review the dog-age solution

Not started

Review the original solution recording and explain each arithmetic step.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob traces 5 minus 2 to 3, multiplies by 4 and adds 21 to get 33, then returns human_age.
Rob’s comic strip · Function challenges

ORIGINAL WALKTHROUGH · 2:21

Watch with Rob.

Pause whenever you want to try a change. You can return to the lesson at any time.

LEARN WITH THE CODE ZONE

Unlock this video walkthrough

Written lessons and coding practice are free. Video walkthroughs are included with a paid Code Zone membership or an active free trial.

Have a Code Zone website account? Use your learning account’s email to get a six-digit sign-in code, or use your existing website password.

Need a website account? Paid Skool members and active trial members can use the email from their membership questions to request a sign-in code. No invite link or Skool password needed.

Close this window to keep practicing. After signing in, you’ll return to this lesson.

Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.

Open video & code editor (opens in a new tab)

Starter source code for VS Code

Copy the source below or download the file to follow along in VS Code.

The download includes a lesson link in each file and a README so you can find your way back.

main.py
main.pypython · example
def calculate_human_age(dog_age):
    human_age = (dog_age - 2) * 4 + 21
    return human_age

five_year_result = calculate_human_age(5)
ten_year_result = calculate_human_age(10)
print(five_year_result)
print(ten_year_result)

Follow one call from start to finish

For calculate_human_age(5), dog_age is 5. The parentheses produce 3; multiplication produces 12; adding 21 produces 33. return human_age sends that number back to the call.

The same body uses 10 for the second call: 8 * 4 + 21 gives 53. A single formula handles both inputs.

Original formula with explicit caller results
dog_age.pypython · example
def calculate_human_age(dog_age):
    human_age = (dog_age - 2) * 4 + 21
    return human_age

five_year_result = calculate_human_age(5)
ten_year_result = calculate_human_age(10)
print(five_year_result)
print(ten_year_result)
Open workspace to paste this example (opens in a new tab)

Compare behavior, not identical spelling

A direct return of the expression is also valid. Your local variable name can differ as long as the requested function and caller names remain intact. Printing inside the function is different: the caller would receive None without a return.

The review workspace is separate from the scored practice. Use it to try new ages while leaving your submitted or saved challenge unchanged.

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

3 steps · Saved work · Instant feedback

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

Next, apply the same input–calculation–return pattern to temperatures.