Introduction to Python and Basic Output
From the ICT curriculum
TL;DR
Python is a popular, easy-to-read programming language that lets you tell computers what to do step-by-step. The print() function is your main tool for showing text or results on the screen. Understanding how print() works is crucial for seeing your program's output and debugging.
1. The Mental Model
Think of Python as a chef following your recipe. You write instructions (code), and Python executes them. The print() function is like the chef showing you a specific ingredient or the final dish on a plate.
2. The Core Material
Python is a high-level programming language, meaning it's closer to human language than to machine code. This makes it easier to learn and use. It's also interpreted, so you don't need to compile your code before running it; Python executes it line by line.
A fundamental part of programming is being able to see what your program is doing. This is where output comes in. In Python, the primary way to display output to the user (or to yourself for debugging) is using the print() function.
The print() Function

Photo by wutthichai charoenburi on Pexels
The print() function simply displays whatever you put inside its parentheses () to the console (your screen).
print("Hello, world!")
When you run this code, it will show:
Hello, world!
You can print different types of information:
- Text (Strings): Always put text inside single quotes (
') or double quotes ("). These are called strings.
python print('This is a string.') print("Another string example.") - Numbers: You don't need quotes for numbers.
python print(123) print(3.14) - Variables: You'll learn more about variables soon, but they are names that store data.
python message = "Python is fun!" print(message) - Results of calculations:
python print(5 + 3) print(10 / 2)
Combining Output with Commas

Photo by Google DeepMind on Pexels
You can print multiple items separated by commas. Python will automatically put a space between them.
print("My name is", "Alice", "and I am", 30, "years old.")
Output:
My name is Alice and I am 30 years old.
Newlines
By default, print() adds a new line character at the end of its output, meaning the next print() statement will start on a new line.
print("First line.")
print("Second line.")
Output:
First line.
Second line.
You can change this behavior using the end parameter, but we'll cover that later when you're more comfortable.
Here's a diagram showing the basic flow of running a Python script with print statements:
graph TD
A["You write Python code (.py file)"] --> B{"Does code have print() statements?"}
B -- Yes --> C["Python Interpreter reads code line by line"]
C --> D["When print() is encountered"]
D --> E["Content inside print() is displayed on screen"]
E --> C
B -- No --> F["Program runs without visible output (unless errors)"]
3. Worked Example
Let's say you want to display a simple greeting and a calculation.
# Step 1: Print a welcoming message
print("Welcome to your first Python program!")
# Step 2: Print a simple arithmetic calculation
print("The sum of 15 and 27 is:", 15 + 27)
# Step 3: Print a message combining different types of data
user_name = "Charlie"
favorite_number = 7
print("Hello,", user_name, "! Your favorite number is", favorite_number)
When you run this code, the output will be:
Welcome to your first Python program!
The sum of 15 and 27 is: 42
Hello, Charlie ! Your favorite number is 7
4. Key Takeaways
- Python is an easy-to-read, interpreted programming language.
- The
print()function is essential for displaying output to the console. - You can print strings (text in quotes), numbers, variables, and calculation results.
- Use commas to combine multiple items in a single
print()statement; Python adds spaces automatically. - Each
print()statement typically outputs on a new line by default.
Common Mistakes to Avoid

Photo by KATRIN BOLOVTSOVA on Pexels
- Forgetting to put text inside quotes (
"or'). This will cause aNameError. - Forgetting the parentheses
()afterprint. This will cause aSyntaxError. - Mixing single and double quotes (e.g.,
print("Hello.'). Stick to one type for a string. - Misspelling
print(e.g.,Print,prnt). Python is case-sensitive.
5. Now Try It
Write a Python script that calculates the area of a rectangle. Define two variables, length and width, set them to 10 and 5 respectively. Then, calculate the area and use print() to display a message like: "The area of a rectangle with length 10 and width 5 is 50."
What success looks like: Your script runs without errors and produces the exact output shown above.
Frequently asked about Introduction to Python and Basic Output
Study this next
Get the full ICT curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free