In this section, we're going to learn how to print to the console.
Printing to the console allows us to see the results of our program,
and can help us find bugs if we make any mistakes. To print to the
console, we can use Python's built-in function
print is an example of a function in Python.
Functions have a unique name, and to use them, we simply write their
name followed by a pair of parentheses. Often, functions need extra
information called arguments in order to work, which are included
inside the parentheses:
# Hello World!
When we run our program, we can see the string in the parentheses shows
up in the console!
We can print almost anything in Python, including numbers, variables,
greeting = "hello"
Python strings also have certain special characters. The most important
\n (creates an extra line)
\t (adds a tab)
If we take the line from before,
\t before "Hello", and replace the space with a
\n, "Hello" will now be indented, and the output will
appear on two lines:
We can use these special characters and more to make our strings look
exactly the way we want when printing to the console.