← back to unit
Easy
# basics functions
Returning a Value
return sends a value back to wherever the function was called, so you can store it or use it:
def double(n):
return n * 2
result = double(5)
print(result)
prints: 10
Your turn: we've already read a number into n for you. Define a function double(n) that returns n * 2 (don't print inside the function), then print what double(n) returns.
💡 need a hint?
pyb-func-return.py🔒 given lines are locked — write your code in between
loading...