Python Print Function

The print function shows information to the user of our program. This can be useful to show the user what the program is doing when we execute it. We run the print function by specifying the function name (print) and adding parentheses after it.

Open Python so it shows the interpreter:

>>>

And then try these examples.

Let’s try a print:

print()

Will show you:


This tells Python to execute the function. We don’t see anything on our screen, but this produces an invisible newline character, which shows up as a blank line on your screen. This is the equivalent of hitting Enter in a text editor.

If we want to see something on our screen, we have to tell the print function what to print between the parentheses and encapsulated with quotes. For example:

print("Hello World")

Will result in this output:

Hello World

When you execute this code, it shows us “Hello World”.

Sign up for FREE to Continue Reading

Here's what you'll get:

  • Full Access to this lesson + 387 more.
  • Learn CCNA, CCNP and CCIE R&S. Explained as simple as possible.
  • Unlock Access to 424 lessons by becoming a member.
  • New Lessons Added Regularly. You'll Be the First to Know.
  • Content created by Rene Molenaar (CCIE #41726)

Takes 1 minute - No credit card needed


Ask a question or start a discussion by visiting our Community Forum