DEV Community

Ramesh S
Ramesh S

Posted on

Python for Beginners — Part 1: Getting Started & Syntax

A beginner-friendly series on learning Python from scratch, one concept at a time.

If you've ever wanted to learn programming but felt intimidated by curly braces, semicolons, and confusing syntax — Python is where you start breathing easy. It reads almost like English, and it's one of the most in-demand languages in the world today, used everywhere from web apps to data science to automation scripts.

This is Part 1 of a beginner series that will take you from "what even is Python" to writing real, working programs. Let's begin.

What is Python?

Python is a general-purpose programming language created by Guido van Rossum and first released in 1991. It's popular because of three big reasons:

  • It's beginner-friendly. The syntax is clean and close to natural language.
  • It's versatile. You can build websites, automate tasks, analyze data, train machine learning models, or write small scripts — all with Python.
  • It has a massive ecosystem. Thousands of ready-made libraries mean you rarely build things from scratch.

Python runs on Windows, macOS, and Linux, and it's free and open source.

Installing Python

Most systems can run Python after a quick install:

  1. Go to python.org/downloads and grab the latest stable version.
  2. During installation on Windows, make sure to check "Add Python to PATH" — this saves you a lot of headaches later.
  3. Verify the install by opening your terminal (Command Prompt, PowerShell, or your Mac/Linux terminal) and typing:
python --version
Enter fullscreen mode Exit fullscreen mode

If you see something like Python 3.13.0, you're good to go.

Tip: On some systems (especially macOS/Linux), you might need to type python3 instead of python.

Your First Python Program

Open a terminal, type python, hit Enter, and you'll land inside the Python interactive shell. Try this:

print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

You should see:

Hello, World!
Enter fullscreen mode Exit fullscreen mode

Congratulations — you just wrote your first Python program. print() is a built-in function that displays output on the screen.

For anything beyond one-liners, you'll want to write code in a .py file instead of the shell. Create a file called hello.py:

print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

Then run it from your terminal:

python hello.py
Enter fullscreen mode Exit fullscreen mode

Python Syntax: The Basics

Python's syntax is what makes it stand out from languages like Java or C++. Here's what you need to know early on.

No semicolons, no curly braces

Most languages need ; to end a line and {} to define blocks of code. Python uses neither. Instead, it relies on line breaks and indentation.

print("This line ends with nothing special")
Enter fullscreen mode Exit fullscreen mode

Indentation defines structure

This is the single most important rule in Python. Indentation (spaces at the start of a line) isn't just for readability — it's part of the language's syntax. It tells Python which lines belong together.

if 5 > 2:
    print("Five is greater than two!")
Enter fullscreen mode Exit fullscreen mode

The line print("Five is greater than two!") is indented, which tells Python it belongs inside the if block. If you don't indent it, Python will throw an error:

if 5 > 2:
print("This will cause an IndentationError")
Enter fullscreen mode Exit fullscreen mode

Rule of thumb: use 4 spaces per indentation level, and stay consistent. Most code editors do this automatically.

Case sensitivity

Python treats uppercase and lowercase letters as different. age, Age, and AGE are three separate variables.

One statement per line (usually)

Unlike some languages, you generally write one instruction per line in Python:

x = 5
y = 10
print(x + y)
Enter fullscreen mode Exit fullscreen mode

You can squeeze multiple statements onto one line using a semicolon, but it's considered bad style and rarely used:

x = 5; y = 10; print(x + y)
Enter fullscreen mode Exit fullscreen mode

Comments in Python

Comments are notes in your code that Python ignores when running the program. They're there purely for humans — to explain what the code does, leave reminders, or temporarily disable a line.

Single-line comments

Use a # symbol:

# This is a comment
print("Hello, World!")  # This prints a greeting
Enter fullscreen mode Exit fullscreen mode

Anything after # on that line is ignored by Python.

Multi-line comments

Python doesn't have a dedicated multi-line comment symbol, but there are two common workarounds:

Option 1 — a # on every line:

# This is a comment
# written across
# multiple lines
print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

Option 2 — a multi-line string that isn't assigned to anything:

"""
This is also
a comment,
technically a string Python evaluates and discards
"""
print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

This second method isn't a "true" comment (it's a string literal Python briefly creates and throws away), but it's commonly used for quick documentation blocks.

Why This Matters

Indentation and clean syntax aren't just stylistic choices in Python — they're enforced by the language itself. This is intentional. Python's design philosophy ("The Zen of Python") leans heavily on readability: code should look the same regardless of who wrote it. Once this clicks, you'll find Python code far easier to read than most other languages, even months after you wrote it yourself.

What's Next

In Part 2, we'll cover variables, data types, and numbers — how Python stores information, the rules for naming variables, and how to work with different types of data.


This is Part 1 of a beginner Python series. Follow along for the rest of the series covering strings, control flow, functions, collections, error handling, and object-oriented programming.

Top comments (0)