Contact
Evil Genius SocietyHomeLearnForumLeaderboardSocialsMessages
← Back to module

Lesson 2 of 10

Every programmer's first program prints a message to the screen. In Python, you do that with the print() function:

print("Hello, world!")

That's it — one line. print(...) takes whatever you put inside the parentheses and displays it as output. The quotes tell Python "this is text" (we'll cover that more in the next lesson).

Calling a function

print is a function — a reusable, named piece of code that does something when you call it. You call a function by writing its name followed by parentheses (). Anything you put inside the parentheses is an argument you're passing to it.

print("Learning Python")
print("one line")
print("prints on its own new line")

You can also print multiple things at once, separated by commas — print will space them out for you automatically:

print("The answer is", 42)

The REPL

Outside of running full scripts, Python also has a REPL — a "Read-Eval-Print Loop." It's an interactive prompt where you type one line of code at a time and immediately see the result. It's what you get when you type python (or python3) in a terminal with no filename after it.

The REPL is great for quickly testing an idea without creating a whole file. The exercise boxes in this course work a lot like a REPL: you write code, run it, and immediately see the output.

Try it yourself

Print your name, then print a short sentence about why you're learning Python — as two separate print() calls.

Checkpoint

  • print() is a function that displays output.
  • Text arguments go inside quotes.
  • The REPL lets you run Python one line at a time, interactively.

Questions about this lesson

Log in to ask a question.