← Python from Scratch
Lesson 42 of 78 · 5 XP
Warm-up: your first function warm-up
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
A function is a piece of code with a name. def creates it, and return gives the result back to whoever called it:
def plus_one(n):
return n + 1
print(plus_one(4)) # 5
Task. Write a function double(n) that returns the number multiplied by 2.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.