Skip to main content

The Print Function: Recording Your First Entry

In the world of The Python Ledger, every action needs a record. To "speak" to the outside world, Python uses a built-in tool called a function. The most important one for a beginner is the print() function.

What is a Function?

Think of a function as a small machine. You give it some "raw material" (input), it processes it, and it produces a result (output).

For print(), the input is whatever you put inside the parentheses (), and the output is that text appearing in your console.

note

We will learn more about funtions in Python later in the course.

Strings: The Language of Text

When we want Python to treat something as plain text rather than a command, we wrap it in quotes. In programming, a sequence of characters inside quotes is called a String.

You can use either single quotes (') or double quotes ("), as long as they match:

Python Sandbox

Special Characters: The New Line

Sometimes you want your Ledger entry to span multiple lines, but you don't want to write ten different print() statements. Python uses the backslash (\) as an "Escape Character" to perform special tricks.

The most common one is \n, which stands for New Line.

Python Sandbox

🏆 The Ledger Challenge: The Signature

To complete this lesson and verify your "Ledger" is working correctly, you need to sign your work.

Task: Use a single print() function and the \n character to print a 3-line signature that looks like this:

NAME: [Your Name]
DATE: 2026-03-18
STATUS: Active
info

Comments are peaces of text that are ignored by the programming languege, but are useful to us - the developers.

Single line comments in Python start with the character #. Everything after # is considered a comment.

Write your code below:

Python Sandbox
Read more about print() function

print() function has a few other arguments that you can use to further format your text on the screen.

Full function signiture is as follows:

print(*objects, sep=' ', end='\n', file=None, flush=False)

To learn more about this specific function and its arguments, visit:

Other resources:

Next Steps

Now that you can output data, it's time to learn how to store it.