Zum Inhalt springen
KodeTrail

Camp 1 · Schritt 2 von 23

Your first program

Write and run real Python code in your browser — and join a fifty-year tradition of first programs.

10 Min.+50 XPAuf Englisch angezeigt — Übersetzung ist unterwegs

Time to write actual code. By the end of this page you'll have run your first Python program and modified it to make it your own. That's not a small thing — most people never get this far.

Hello, World!

Since the 1970s, the traditional first program prints the words Hello, World! on the screen. Yours is below — and it's live. Press Run:

Python

The first run loads Python into your browser, so it can take a few seconds — after that it's instant.

Congratulations, you're officially a programmer. 🎉

Reading your first line

Let's slow down and look at what each piece means:

print("Hello, World!")
  • print is a function — a named action Python knows how to do. This one means "show something on the screen."
  • The parentheses (...) hand the function whatever it should work with.
  • "Hello, World!" is a string — a piece of text. The quotes tell Python "this is text, not code."

More than one instruction

Programs run instructions top to bottom, in order. Each print produces its own line:

Python

Try reordering the lines and running again — the output order follows the code order, always.

Checkpoint

What will this program print?

print("A")
print("C")
print("B")

Numbers work too

print isn't limited to text. Give it math and Python calculates first, then prints the result:

Python

Look closely at the last line: with quotes, "7 + 3" is just text, so Python prints it as-is. Without quotes it's a calculation. The quotes make all the difference — a distinction we'll explore properly soon.

Checkpoint

What does print(2 + 2) show?

What's next

You can now make Python say things. Next you'll learn the finer points of printing — combining several values, blank lines, and a few tricks that make output easier to read.