TracksPractical Coding FoundationsWriting Your First Lines of CodeWriting and Running Your First Program(1 of 11)

Writing and Running Your First Program

This is the moment everything comes together. You'll create a file, write code, save it, and run it — completing the full cycle that every programmer repeats thousands of times. The traditional first program prints "Hello, World!" to the screen, and there's good reason for this tradition: it proves your entire setup works.

Creating Your Program File

First, navigate to your workspace folder in the terminal. Then create a new file called hello.py:

cd ~\workspace
New-Item hello.py

Writing the Code

Open hello.py in VS Code (or your preferred editor) and type this single line:

print("Hello, World!")

That's it — your complete first program. The print() function tells Python to display text on the screen. The text inside the quotes is what gets displayed.

Save the file. In VS Code, press Ctrl+S (Windows/Linux) or Cmd+S (macOS).

Running Your Program

Return to your terminal (or use VS Code's integrated terminal). Make sure you're in the folder containing hello.py, then run:

You should see Hello, World! appear in your terminal. Congratulations — you just ran your first program!

What Just Happened

Let's break down what occurred:

  1. You typed python3 hello.py and pressed Enter
  2. Your shell found the Python interpreter
  3. Python read your hello.py file
  4. Python executed the print() instruction
  5. The text appeared in your terminal
  6. The program finished, returning you to the prompt

This cycle — edit, save, run, observe — is the heartbeat of programming.

Try a Variation

Change your program to print something different:

print("Hello, World!")
print("My name is Alex.")
print("I am learning to code!")

Save and run again. Each print() statement creates a new line of output.

You're a Programmer Now

This might seem simple, but you've just done something significant. You've given instructions to a computer and watched it follow them. Every complex application — every website, every game, every app on your phone — started with someone writing simple instructions like this.

The programs will get more interesting from here. You'll learn to store information, make decisions, repeat actions, and build real tools. But the fundamental process stays the same: write code, run it, see what happens, improve it.

Welcome to programming.

See More

Further Reading

You need to be signed in to leave a comment and join the discussion