The dragon explains
The Dragon's Two Abilities
The dragon: You've learned three things about functions. Let's put them together for the final challenge.
The dragon: One: def names a group of code, and calling it runs that code again from the top.
The dragon: Two: parameters let one function produce different results for different calls.
The dragon: Three: a function that returns hands a value BACK — deliver() is how you actually send that value on.
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.
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
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
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 PROStuck three times? The game offers the answer — unasked.