Skip to content
Your First Program
step 1/7

Reading — step 1 of 7

Learn

~2 min readGetting Started

There's a tradition in programming. When you learn a new language, the very first thing you do is make the computer say "Hello, World!" It sounds trivial — and it is — but it proves something important: your tools work, you understand the basic syntax, and you can make a machine do exactly what you want. That's the entire game of programming, right there.

What print actually does

When you write print("Hello, World!"), you're calling a built-in function. The function print takes whatever you put inside its parentheses and sends it to the screen — specifically, to the program's standard output, which the terminal then displays.

Three separate things have to be right for that one line to work:

  1. The function name: print. Lowercase, exactly. Print won't work. PRINT won't work.
  2. The parentheses: (). They tell Python "call this function with the following arguments." Forgetting them gives you a famous beginner error: print "Hello" was the syntax in Python 2, and it does not work in Python 3.
  3. The string: "Hello, World!". The double quotes are not part of the message — they tell Python where the text starts and stops. Single quotes work just as well: print('Hello, World!').

Strings — text in code

A string is just text. To put text in your program, wrap it in matching quotes:

python

Both work. Pick a style and stay consistent. The only time it matters is when your text contains a quote: print("It's working") is fine because the apostrophe inside doesn't conflict with the double quotes outside.

Comments — notes for humans

The # symbol starts a comment. Python ignores everything from # to the end of the line. Comments are for the humans reading your code — you, your teammates, your future self at 3am trying to remember what this script was for.

python

Common beginner errors

  • SyntaxError: invalid syntax — usually a missing ), mismatched quotes, or print "x" instead of print("x").
  • NameError: name 'print' is not defined — almost always a typo: Print(...), PRINT(...), or prnt(...).
  • Mixing quote styles: print("hello') doesn't work — the opening and closing quotes must match.

Multiple lines

Python runs your file top to bottom, one line at a time. Multiple print calls produce multiple lines:

python

Each call automatically adds a newline at the end, which is why each print lands on its own line.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…

Your First Program — Python Fundamentals