Module 4 · Functions · Lesson 3 of 4
Where functions come from
You've already been calling functions — print(), len(), input(). So where do functions actually come from? There are three sources, and the lovely part is that you call all of them the same way: a name, then parentheses.
Three sources, one way to call
built into Python
print() len() input()
from a module
math.sqrt() random.randint()
written by you
def greet(): ...
📞
call it!
- Built in. A core set comes with Python and is always ready — print, len, input, sum, and more.
- From a module. Python ships with a huge standard library; you import a module like math or random to unlock its functions.
- Written by you. When nothing existing fits, you define your own with def — exactly what we'll do next.
Run it yourselfruns in your browser · Python
main.py
Built-in, imported, or your own — once a function exists, calling it looks identical. That consistency is what makes Python feel so approachable. Time to write one yourself.