Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Your First Program · Lesson 4 of 11

Your First Python Program

A free lesson from Swipe Coding · Python, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
No setup ceremony here — a Python program can be one line in one file. Let's write it. 🐍

A Python program is simply a plain text file saved with a .py extension, such as hello.py. There is nothing more you need to set up before you can start writing actual, working code inside it.

This is quite different from Java, where every runnable program must live inside a class, with a public static void main(String[] args) method acting as the required entry point — boilerplate you have to write before a single line of your own logic runs. Python has no such requirement: a file can contain just one line, and that line is the entire program.

print("Hello, World!")
Save this single line in a file named hello.py — that is the entire program. No class, no main method, nothing else needed.
🤖
No main() to hunt for — Python just starts at line one and goes. 🐍

When you run a Python file, the interpreter reads it from top to bottom and executes each statement in the order it appears. There is no special starting point you need to declare, like main() in Java — the first line of the file is simply the first thing that runs.

Fill in the blank

Unlike Java, a runnable Python program does not need to be wrapped in a ____ or a main method.

By convention, Python files use lowercase names, with underscores separating words if needed — for example hello_world.py rather than HelloWorld.py. This lowercase, underscore-separated style (called snake_case) shows up throughout Python, not just in file names.

Quick check

What must every Java program have that a Python program does not?

True or false

In Python, the interpreter runs the statements in a file from top to bottom, in the order they appear.

Keep your streak going in Swipe Coding

Swipe through every level of Python on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →