Kids Coding

Functions that Return

return sends a value back. Call the function. Use the result.

KidsAdvancedFunctions that Return

Give a value back

print shows something. return hands a value to whoever called the function. You can store it and use it.

score()

def score(points):
    return sum(points)

total = score([10, 20, 5])
print("Total:", total)

print shows a value on the screen; return hands it back so the rest of your code can use it. A function that only prints cannot be added up, saved, or checked later.

Return vs print

printreturn
You see itYesOnly if you print the result
You can reuse itNoYes — put it in a variable

Use the result twice

def double(n):
    return n * 2

value = double(4)
print(value)
print(value + 1)

Real life

A shop calculator: you want the number back, not just to see it.

print shows the total. return hands it to you so you can pay, or save, or add a bag.

Shop total

def total(price, count):
    return price * count

pay = total(3, 4)
print("Pay", pay)
print("If I buy one more:", pay + 3)

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Write add(a, b) that returns a + b. Print add(3, 4).

Show solution
def add(a, b):
    return a + b

print(add(3, 4))

FAQ: Functions that Return

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run functions that return examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn functions that return in this Kids Coding Python lesson (Functions that Return).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.