What is a Program? Meet print()

Getting your computer to speak its very first words using Python

Imagine having a super-fast robot friend who can do anything, but has absolutely no common sense. To make it do a single thing, you have to give it perfect instructions in a language it actually understands. Today, you are going to learn how to give this robot its very first instruction: speaking to you!

Words to own

Program
A list of exact instructions that a computer follows step-by-step, in order, without skipping.
print()
A built-in Python command that displays text or numbers on the screen.
String
Any text data wrapped in quotation marks, like "Hello!".
Syntax
The exact rules for spelling, punctuation, and brackets that a programming language needs to run.
Variable
A named container used in code to store information that can change.
Error
A mistake in code that prevents the program from running or working properly.

The Recipe for Computing

A program is not magic. It is just a list of exact instructions, followed one line at a time, in order, from top to bottom. Think of it like baking a cake. If a recipe says 'crack the eggs' and then 'bake the cake,' you have to do those steps in that exact order.

Computers are incredibly fast, but they are also completely literal. If you leave out a step, or write it out of order, the computer will not guess what you meant. It will either do the wrong thing or crash!

Strings (Text) vs. Numbers in print()
PointString (Text)Number
Needs Quotes?Yes (e.g., "Hello")No (e.g., 7)
What Python ThinksIt treats it as literal text characters.It treats it as a numerical value it can do math with.
Example Codeprint("100")print(100)
Adding Them Togetherprint("10" + "20") prints "1020"print(10 + 20) prints 30

Say Hello to print()

The very first command almost every programmer learns is the print() function. This is how you give your computer a voice. It tells Python to display whatever you put inside the round brackets directly onto your screen.

To make Python speak, we write the word print, open a round bracket, put our message inside, and close the bracket. This is our first official line of code!

Writing your very first line of Python code
print("Hello, world!")
Output
Hello, world!

Why Quotes Matter

Did you notice the double quotation marks around 'Hello, world!'? In programming, text is called a string because it is a 'string of characters' joined together. Python needs those quotes to know that 'Hello, world!' is just plain text to print.

If you forget the quotes, Python gets confused. It thinks you are typing a command or looking up a secret container (called a variable). Since it cannot find a variable named Hello, it throws an error and refuses to run.

Comparing what happens with and without quotes
print("Hello")
# print(Hello)  <-- This line would cause an Error!
Output
Hello

Mixing Words and Numbers

Python is excellent at math, and numbers are a completely different type of data than text. Because of this, numbers do not need quotation marks. If you print a number, Python displays it perfectly.

You can even mix text and numbers together in a single print() command by separating them with a comma. Python will automatically put a nice, clean space between them for you!

Printing a number and mixing data types together
print(7)
print("The answer is", 7)
Output
7
The answer is 7

What is Syntax?

Human beings are great at understanding messy language. If someone says 'pleese pass the salt', you still know what they want. Computers cannot do this. They require perfect grammar, which programmers call syntax.

Syntax is the exact spelling and punctuation rules that your code must follow. If you miss a round bracket, forget a quote mark, or spell print as 'prnt', the computer will simply stop and show a 'SyntaxError'. Learning to code is largely about learning these exact rules.

Your turn — run real Python

Python's First Greeting

Create a program that prints a welcome message to a coding academy, states your name, and does a simple math calculation on a new line.

1
2
3

Bug hunt

What is wrong with this code?

print("Hello World)

Myth-busting corner

  • MythIf I make a small spelling error like 'prnt()', Python will figure out what I meant and run the code anyway.

    TruthComputers are completely literal. A small spelling error will cause a SyntaxError and stop the whole program from running.

  • MythYou have to put quotes around everything inside print(), including numbers.

    TruthNumbers do not need quotes. If you put quotes around a number (like "7"), Python treats it as text, which means you cannot easily use it for math calculations.

Exam answer that scores full marks

Predict the exact output of this code, and explain your reasoning: print("I have", 3, "cats")

The output will be: I have 3 cats. This works because print() can take multiple pieces of information separated by commas, and it automatically joins them together with spaces in between when displaying them. Here, "I have" is a string (text in quotes) and "cats" is also a string, while 3 is a number that doesn't need quotes. Python prints each piece in order, separated by a space, producing one combined line of output — this is a really common and useful pattern for mixing fixed text with changing values.

Why it scores

  • Correctly predicts the exact output with spaces in the right places.
  • Explains that commas in a print statement automatically add spaces.
  • Identifies the difference between string data types (in quotes) and number data types (without quotes).