Practice Challenge: Choosing print() or return in Python

print() shows it, deliver() sends it — choosing the right channel for each function.

  • Lesson 4 of 5
  • PRO
  • Ages 10+
  • 3 hands-on levels
See what PRO unlocksA one-time $49.99 purchase. Topics 1–3 are free.

The dragon explains

The Dragon's Two Abilities

  1. The dragon: You've learned three things about functions. Let's put them together for the final challenge.

  2. The dragon: One: def names a group of code, and calling it runs that code again from the top.

  3. The dragon: Two: parameters let one function produce different results for different calls.

  4. The dragon: Three: a function that returns hands a value BACK — deliver() is how you actually send that value on.

  5. The dragon: The challenge ahead has two functions with two different jobs. Picking the right channel for each is the whole point.

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 1

    One function's whole job is to SHOW a message. Another's job is to CALCULATE a number for later use. Which one should use return?

    • The one calculating a number — its result needs to be handed back and usedCorrect
    • Both should return, since return is always the more powerful choice

    Why: The calculating one. If a value needs to be USED afterward (added, compared, delivered), it should return. If a function's whole job is just showing something, print() inside it is enough.

In the game

What you'll practice

Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.

  1. 1

    GuidedYour first try

    def compute_total(gold, gems): return gold + gems * 10. Print a label ("TOTAL VALUE:"), then deliver the result of compute_total(20, 3).

  2. +2

    PracticeTwo more, on your own

This lesson is part of PRO.

PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.

Unlock this lesson with PRO

Stuck three times? The game offers the answer — unasked.