Table of Contents
Alright. Python is installed. VS Code is set up. The Python extension is in place. Everything is ready — and now you’re sitting there staring at a blank screen wondering, okay, now what do I actually type?
That feeling, by the way, never fully goes away. Even experienced programmers stare at a blank file for a moment before starting. You’re in good company.
So let’s break that blank screen together. We’re going to write our very first Python program, understand exactly what each part does, and actually run it.
Let’s go.
Step 1 — Open a Folder in VS Code
Before writing any code, let’s give our work a home. Think of it like this — you wouldn’t just dump a new document on your Desktop with no folder. Same logic applies here.
In VS Code, go to File > Open Folder. Create a new folder somewhere on your computer — name it something like my-python-projects — and open it. VS Code will now treat this folder as your workspace.
You’ll see it appear in the Explorer panel on the left. Clean, organised, ready.
Step 2 — Create Your First Python File
In the Explorer panel, click the New File icon (it’s a tiny page with a + sign). Name it hello.py and hit Enter.
That .py extension is important. It tells VS Code — and your computer — that this is a Python file. Without it, VS Code won’t know to treat it as Python, and your syntax highlighting and extension features won’t work. Always end your Python files with .py.
The file opens in the editor. Still blank. Let’s fix that.
Step 3 — Write Your First Line of Code
Type this into your file:
That’s it. One line. Your first Python program is written.
print("Hello, World!")
Now before we run it, let’s actually understand what we just typed — because knowing what you’re writing matters a lot more than just seeing it.
What is print() ?
Good question. Let’s break it down.
In Python, print() is a built-in function. A function is essentially a pre-written set of instructions that does a specific job. You call it by its name, give it something to work with, and it does its thing.
Think of it like ordering at a restaurant. You say “I’ll have the pasta” — you don’t go into the kitchen and cook it yourself. The kitchen (the function) already knows what to do. You just placed the order.
In this case, you’re telling Python — “display this on the screen.” And print() does exactly that.
Now let’s look at what’s inside the brackets:
"Hello, World!"
The text inside the quotes is called a string — which is just programmer-speak for text.
Whenever you want Python to treat something as text (rather than a number or a command), you wrap it in quotes. Single quotes work too:
print('Hello, World!')
Both are valid. Double quotes, single quotes — Python doesn’t mind. Just be consistent.
Step 4 — Save the File
Press Ctrl + S on Windows or Cmd + S on Mac. You’ll notice the dot on the file tab disappears — that means it’s saved.
Get into the habit of saving before running. Always. It’ll save you minutes of confusion wondering why your changes aren’t reflecting.
Step 5 — Run the Program
The moment of truth. Two ways to run it:
Option A — The Easy Way:
Click the Run button — the little triangle (▶) at the top right of VS Code. Click it. A terminal will appear at the bottom of your screen and show:
Hello, World!
Option B — The Terminal Way:
Open the integrated terminal in VS Code with Ctrl + ` (the backtick key, just below Escape). Then type:
python hello.py
On Mac, remember to use:
python3 hello.py
Either way, your output is:
Hello, World!
There it is. Your computer just executed your instructions. You told it what to do, and it did it. That’s programming — in its purest, most honest form.
Let's Play With It a Bit
Now that it’s working, don’t just stop. Change the text inside the quotes to anything you want:
print("CodexStudio is live!")
Or run multiple print statements:
print("Line 1")
print("Line 2")
print("Line 3")
Each print() gives a new line of output. Python reads your code from top to bottom, line by line, and executes each instruction in order.
Simple, logical, predictable.
That top-to-bottom execution is actually one of the reasons Python is such a great first language — it behaves the way your brain expects it to.
Key Takeaways
- print() is a built-in function — it displays output on the screen
- Text inside quotes is called a string — both single and double quotes work
- Always save your file (Ctrl/Cmd + S) before running
- Python files must end in .py
- Python executes code line by line, top to bottom
- On Mac, use python3 hello.py — on Windows, use python hello.py
One line of code. One function. One output. It doesn’t look like much yet, but this is genuinely the foundation everything else is built on. Every app, every website, every AI model — it all started with someone running their first print statement and thinking, wait, it actually worked.
Now you’ve had that moment too. Keep it up!
