Basics

Module 2 · Basics · Lesson 2 of 9

The print() function

You've been using print since your very first program. It's worth a proper look, because it shows off three ideas that hold for every function in Python: what you put in, the effect it has, and the value it returns.

What goes in, what comes out
"Hello"
print()
Hello
effect — shown on screen
None
returned value — nothing useful

What you put in are its arguments — the values inside the parentheses. Its effect is the visible thing it does: writing those values to the screen. That's why you use it — to see what your program is doing.

The third idea is subtler. Every function call also returns a value back to your code — and print's returned value is None, Python's way of saying “nothing useful here.” That makes sense: you call print for its effect, not to get something back. Plenty of other functions you'll meet are the opposite — their whole point is the value they return. Keeping effect and returned value apart will save you confusion later.

Next, let's zoom in on those arguments — the data you actually hand the function.