Module 0 · Functions, Variables · Lesson 1 of 5

Talking with print

A function is an action Python already knows how to perform. You call it by writing its name followed by parentheses. Whatever you put inside the parentheses is an argument: the input you hand to the function.

print("hello, world")

Text in quotes is a string (str). Forget a quote or a parenthesis and Python stops with a SyntaxError. That's normal: everyone hits it daily.

print accepts several arguments separated by commas, and joins them with a space. It also has two named parameters with default values:

  • sep=" " is what goes between arguments.
  • end="\n" is what goes after the last one. \n means "new line".

Reading the docs is a real skill. The official signature is print(*objects, sep=' ', end='\n'). The * means "any number of arguments".

Try it

Edit freely · Ctrl+Enter runs

Quick check0 of 3 right

What does print("A", "B", sep="") show?

What is the default value of print's end parameter?

Which line causes a SyntaxError?

Practice0 of 2 solved

1. Ready, set, goTo do

Print Ready...Set...Go! using one call to print with three separate arguments. Let sep do the joining.

InputOutput
(no input)Ready...Set...Go!

2. Two prints, one lineTo do

Use two calls to print that together show hello, world on a single line.

InputOutput
(no input)hello, world