惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
IT之家
IT之家
B
Blog
博客园_首页
量子位
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
J
Java Code Geeks
H
Help Net Security
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Python for Beginners — Part 1: Getting Started & Syntax
Ramesh S · 2026-06-20 · via DEV Community

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

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!")

You should see:

Hello, World!

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!")

Then run it from your terminal:

python hello.py

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")

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!")

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")

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)

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)

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

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!")

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!")

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.