Your first Python program: print statements and basic syntax

Writing your first Python program is a small step technically, but it is an important moment in learning to code. This is the point where programming stops being an abstract idea and starts becoming something practical. You type instructions, Python reads them, and the computer produces a result. That feedback loop is the core of learning programming.

For absolute beginners, the first lesson should be simple enough to follow without confusion, but meaningful enough to introduce real programming concepts. In Python, that usually begins with the print() function and a few basic syntax rules. These may look trivial at first, but they establish habits that matter later when the code becomes more complex.

This lesson explains how to write your first Python program, how the print() function works, what Python syntax means in practice, and which beginner mistakes are most common in the early stage.

What your first Python program usually looks like

The traditional first program in many programming languages prints a short message to the screen. In Python, that usually looks like this:

print(“Hello, world!”)

This line is simple, but it teaches several things at once.

  • print is the name of a built-in Python function
  • parentheses are used to pass data into that function
  • quotation marks show that the value is text
  • the output appears on the screen when the code runs

Even in this tiny example, you are already learning the basic idea of programming: giving instructions to the computer in a format the language understands.

When you run this program, Python displays:

Hello, world!

That visible result is important. It proves that your Python installation works and that your code can control the output.

What the print() function does

The print() function displays output. In beginner Python, it is one of the most frequently used tools because it gives immediate feedback. If you want to show text, numbers, variable values, or intermediate results, print() is the standard way to do it.

For example:

print(“Python is working”)
print(42)
print(3.14)

This prints text, an integer, and a decimal number.

The reason print() matters so much for beginners is that it helps you observe what the program is doing. Later, when your code becomes longer, print() is also useful for debugging. You can display variable values and check whether the logic is behaving as expected.

That means print() is not only a teaching tool. It is also a practical development tool.

Why the first Python program matters

Some beginners think the first program is too basic to matter. In reality, it introduces several core habits:

  • writing syntactically correct code
  • saving Python files properly
  • running code through the interpreter
  • reading output
  • connecting written code to visible behavior

This first stage is also where beginners start learning that programming is exact. A missing quote, an extra parenthesis, or incorrect spelling can stop a program from running. That precision can feel strange at first, but it becomes natural with practice.

The first program is not important because of what it does. It is important because of what it starts.

How to create your first Python file

If Python is already installed, the next step is creating a script file. A Python script is usually saved with the .py extension.

For example:

first_program.py

Inside the file, you can write:

print(“Hello, world!”)

Then save the file and run it from the terminal.

On Windows:

python first_program.py

On Linux or macOS:

python3 first_program.py

If the output appears, your first real Python script is working.

This process teaches a beginner three important things:

  • where code lives
  • how Python executes a file
  • how a script becomes output

That is the basic workflow of programming in Python.

Understanding syntax in simple terms

Syntax is the set of structural rules that tell Python how code must be written. Every programming language has syntax rules. If the code breaks those rules, the interpreter cannot understand it properly.

For beginners, syntax often sounds more intimidating than it really is. At this stage, syntax simply means things like:

  • using quotes correctly around text
  • writing parentheses where required
  • spelling function names accurately
  • respecting indentation rules
  • closing brackets correctly
  • using the right punctuation in the right places

Python syntax is considered beginner-friendly because it is relatively clean and readable. Even so, it still requires precision.

Look at this correct example:

print(“Learning Python”)

Now compare it with this incorrect version:

print(“Learning Python)

This fails because one quotation mark is missing.

Here is another incorrect version:

Print(“Learning Python”)

This also fails because Python is case-sensitive, and Print is not the same as print.

These examples show that syntax is not about memorizing abstract grammar rules. It is about writing instructions in a format the interpreter can actually read.

Python is case-sensitive

One of the first syntax rules beginners need to understand is that Python is case-sensitive. That means uppercase and lowercase letters matter.

For example:

print(“Hello”)

is valid, but:

Print(“Hello”)

is not the same thing.

The same rule applies to variables later on. These are different names in Python:

name = “Alice”
Name = “Bob”

They are not treated as the same variable.

This matters because beginners often assume the language will “understand what they meant.” Python does not guess. It follows the exact code you write.

Strings and quotation marks

In the first Python program, text is usually written inside quotes. In Python, text values are called strings.

For example:

print(“This is a string”)
print(‘This is also a string’)

Both double quotes and single quotes can define strings in Python. For beginners, the most important point is consistency and correctness. If you open a string with one kind of quote, it must close correctly.

Correct:

print(“Python”)
print(‘Python’)

Incorrect:

print(“Python’)

That causes a syntax error because the quotes do not match properly.

Strings are one of the most important data types in Python, and understanding them starts here.

Printing multiple lines

You are not limited to one print() statement. A Python script can contain multiple lines, each doing something different.

For example:

print(“Welcome to Python”)
print(“This is my first script”)
print(“It prints several lines”)

When the script runs, each print() call produces output on its own line.

This helps beginners understand that programs are sequences of instructions. Python reads the script from top to bottom in order, unless later logic changes the flow.

That top-to-bottom execution model is one of the first mental models every beginner should understand.

Printing numbers in Python

The print() function does not only work with text. It can also display numbers.

print(10)
print(25)
print(3.5)

This introduces an important point: Python handles different kinds of data, and not everything needs quotation marks.

If you write:

print(“10”)

you are printing text.

If you write:

print(10)

you are printing a numeric value.

The output may look similar on the screen, but internally Python treats them differently. That difference becomes very important later when you start doing calculations and working with data types.

Simple arithmetic in print()

One useful beginner trick is that Python can evaluate simple expressions directly inside print().

print(2 + 3)
print(10 4)
print(5 * 6)
print(8 / 2)

This teaches a critical concept early: Python is not only printing fixed content. It can also calculate results before displaying them.

For beginners, this is often the point where code starts to feel more interesting. The program is no longer just repeating text. It is processing instructions.

You can even combine text and calculations later, although that requires some additional concepts such as variables and formatting.

Comments in Python

Another important part of basic syntax is the comment. A comment is text inside the code that Python ignores. Comments help explain what the code is doing.

In Python, a single-line comment starts with #.

Example:

# This is my first Python comment
print(“Hello, world!”)

The comment is not executed. It exists for humans reading the code.

Comments are useful because they can:

  • explain the purpose of a line
  • describe what a section of code is doing
  • make code easier to review later
  • help beginners remember their own logic

However, comments should support the code, not replace clear code. In beginner lessons, comments are helpful for explanation, but the long-term goal is to write code that is readable even without excessive commentary.

Blank lines and readability

Python ignores blank lines in many simple cases, but they are still useful for structure. A script with carefully spaced sections is easier to read than one where everything is packed together.

For example, compare this:

print(“Start”)
print(“Middle”)
print(“End”)

with a larger script where blank lines help separate sections:

print(“Start”)

print(“Middle”)

print(“End”)

In very small examples the difference is minor, but in real programs readability matters. Python places high value on clean formatting, and beginners benefit from building that habit early.

Indentation is part of Python syntax

One of the most important syntax rules in Python is indentation. In many languages, indentation is mainly for human readability. In Python, indentation also affects structure.

For example, this kind of code uses indentation to show which lines belong inside a block:

age = 18

if age >= 18:
print(“Adult”)

The indented line belongs to the if block. Without correct indentation, Python raises an error or interprets the structure differently.

This is one reason Python looks clean, but it is also one reason beginners must be careful. Indentation is not optional decoration. It is part of the language.

At the stage of the first script, you may not need much indentation yet, but it is worth understanding early because it becomes essential very quickly.

Common beginner syntax errors

Syntax errors are normal. Every beginner makes them. The important thing is learning to recognize the patterns.

Here are some of the most common early mistakes.

Missing quotation mark

print(“Hello)

Python sees that the string never closes.

Missing parenthesis

print(“Hello”

The function call is incomplete.

Wrong capitalization

Print(“Hello”)

Python treats Print and print as different names.

Extra punctuation

print(“Hello”))

One extra parenthesis is enough to break the code.

Indentation problems

Later, when writing conditions or loops, indentation mistakes become very common.

These errors are frustrating at first, but they are part of learning. In fact, reading and understanding error messages is a basic programming skill in itself.

Why error messages are not the enemy

Many beginners react to the first error message as if it means they are failing. That is the wrong way to look at it. Error messages are part of the learning process. They are signals that something in the code needs correction.

For example, if you forget a quote or parenthesis, Python usually points to the line where the syntax broke. The exact wording may feel unfamiliar at first, but over time you start noticing patterns.

A beginner does not need to understand every technical detail in an error message immediately. The first goal is simply to identify:

  • which line caused the issue
  • what kind of structure is incomplete or invalid
  • whether a quote, bracket, name, or indent is wrong

This is one reason beginners improve faster by running lots of small code examples. Frequent testing leads to frequent mistakes, and frequent mistakes lead to faster recognition.

Building confidence with tiny scripts

A common beginner mistake is trying to do too much too early. After one or two successful print() examples, some learners immediately try to build complex programs and then feel overwhelmed.

A better strategy is to make tiny scripts first.

For example:

print(“My name is Daniel”)
print(“I am learning Python”)
print(“This is my third line”)

Then maybe:

print(5 + 5)
print(12 2)
print(3 * 4)

Then combine output types:

print(“The result is:”)
print(10 + 15)

These tiny steps matter. They help you build familiarity with syntax and execution before moving to variables and logic.

Good beginner habits when writing Python code

The first Python lesson is also the right time to build good habits. These habits may seem minor now, but they become valuable later.

Type the code yourself

Do not only read examples. Type them. The act of typing helps reinforce syntax and structure.

Run code often

Do not wait until a long script is finished. Test small parts immediately. Frequent execution makes debugging easier.

Change the examples

After a sample works, modify it. Change the text, change the numbers, add another line, remove something, then see what happens.

Keep files organized

Save your beginner Python files in one clear folder. That reduces confusion when running scripts from the terminal.

Read the output carefully

Do not just check whether something ran. Check whether the result is what you expected.

These habits create a stronger foundation than passive reading alone.

How print() prepares you for later lessons

The print() function may look basic, but it remains useful even after the beginner stage.

Later, you will use print() to:

  • display variable values
  • show user input
  • test conditions
  • inspect loop behavior
  • check function results
  • debug mistakes in logic

That is why the first lesson matters more than it may seem. You are not only learning one function. You are learning the first form of interaction between your code and the visible result.

In a sense, print() is the beginner’s first debugging tool, first feedback tool, and first output tool all at once.

Small practice examples

Here are a few simple exercises suitable for this stage.

Example 1: Basic greeting

print(“Hello, world!”)

Example 2: Multiple lines

print(“Python is fun”)
print(“I am learning step by step”)
print(“This is my first lesson”)

Example 3: Numbers

print(100)
print(20 + 5)
print(8 * 3)

Example 4: Mixed output

print(“The answer is”)
print(42)

Example 5: Comment and output

# This line prints a message
print(“Learning Python syntax”)

These examples are simple on purpose. At this stage, repetition is valuable.

What you should understand before moving on

Before continuing to the next lesson, a beginner should be comfortable with the following:

  • what a Python script file is
  • how to save a file with the .py extension
  • how to run a Python script from the terminal
  • how print() works
  • how strings are written with quotes
  • that Python is case-sensitive
  • that syntax must be exact
  • that errors are normal and fixable

If these basics are clear, then the next lesson becomes much easier. The next major step after this is usually variables, because variables make the output dynamic instead of fixed.

Final summary

Your first Python program is usually built around the print() function and a few simple syntax rules, but that does not make it unimportant. This first stage teaches the essential workflow of programming: write code, run it, read the result, spot mistakes, correct them, and try again. That loop is the foundation of real progress.

Python is especially good for this stage because the syntax is relatively clean and readable. Beginners can focus on understanding what the code does instead of getting buried in boilerplate. The print() function, strings, comments, and simple expressions give enough structure to make programming feel real without becoming overwhelming.

Once you are comfortable writing and running simple Python scripts, you are ready for the next major concept: variables, which allow programs to store and reuse data instead of just printing fixed values.


Image(s) used in this article are either AI-generated or sourced from royalty-free platforms like Pixabay or Pexels.

This article may contain affiliate links. If you purchase through these links, we may earn a commission at no extra cost to you.

Weekly briefing

Get the weekly RF & IT briefing

Radio guides, RF calculators, AI, Windows, Linux and satellite communication explainers. One useful email per week. No spam.

Similar Posts