Courses/Python Mastery/Module 1: What is Python? (Introduction)
Module 1 · Lesson 510 minBeginner

Your First Program: Hello, World!

Lesson goal
Write and run your very first Python program — a rite of passage for every programmer since 1972.

Your First Program: Hello, World!

Since 1972, the first program every programmer writes in every new language prints the words "Hello, World!" on the screen. It started with a Bell Labs tutorial by Brian Kernighan and became a ritual spanning 50 years. Today, you join that ritual.

Step 1: Create the file

Open VS Code. Create a new folder called python-practice (File → Open Folder → create it). Inside, create a new file:

code
hello.py

The .py ending tells everyone — VS Code, Python, you — that this file contains Python code.

Step 2: Write the code

Type this exactly (yes, typing — not copy-paste):

code
print("Hello, World!")

That's it. One line. Let's decode it anyway:

  • `print` — a built-in function: a named action Python already knows. It means "display this."
  • `( )` — parentheses hold what you're giving to the function — its *input*, called an argument.
  • `"Hello, World!"` — a string: text, wrapped in quotes. The quotes tell Python "this is text, not code."
  • Read it out loud: *"print, with the argument 'Hello, World!'"* — and that's exactly what it does.

    Step 3: Run it

    Open the terminal in VS Code (Terminal → New Terminal) and run:

    code
    python hello.py

    Output:

    code
    Hello, World!

    That's your code, executing on your machine. Take the moment. Every programmer you've ever heard of started exactly here.

    Level up: make it yours

    Change the program to print three lines:

    code
    print("Hello, World!")
    print("My name is Galvan")
    print("I am learning Python")

    Run again. Notice: three prints, three lines of output, in order — top to bottom, always.

    code
    print("A", "B", "C")           # A B C — commas add spaces automatically
    print("A", "B", sep="-")       # A-B — sep changes the separator
    print("no newline", end="")    # end="" stops the line break
    print("...continues here")

    You rarely need sep and end early on, but knowing they exist saves confusion later when output appears "on the same line mysteriously."

    Your first error (on purpose — this is important)

    Delete one quotation mark so the line reads:

    code
    print("Hello, World!)

    Run it. You'll see:

    code
    SyntaxError: unterminated string literal (detected at line 1)

    Do not panic. This is a good thing. Read the error slowly:

  • SyntaxError — the *grammar* of your code is wrong
  • unterminated string literal — a string started but never ended (the missing quote)
  • (detected at line 1) — where to look
  • Now fix the quote, run again, watch it work. That cycle — error, read, fix, run — is 80% of programming. You just did it on day one, on purpose. Every time an error scares you, remember: you chose to break this one, and you fixed it.

    Common Errors & Fixes

  • `python: command not found` — Python isn't installed or the terminal doesn't see it. Revisit the installation lesson and check "Add to PATH" during install.
  • `can't open file 'hello.py'` — you're running the command from the wrong folder. Use cd to move into the folder where the file lives first.
  • `SyntaxError: unterminated string literal` — a missing closing quote. Count your quotation marks; they come in pairs.

  • ✅ Checkpoint

  • hello.py runs and prints three lines, in order
  • You broke it on purpose and fixed it — and read the error message slowly
  • You can explain: print = function, quotes = string, parentheses = arguments
  • Next lesson: the first 🧪 Practice Session — five small challenges that lock in everything from Module 1. See you there.