Live
Auto strategy optimizer — AI improves your edge while you sleep
tutorialbeginner10 min

Your First Program

Write and run your first Python program. Learn how code executes and how to see output.

Last updated: Jan 28, 2026

Let's write your first program. By tradition, programmers start by writing a program that displays "Hello, World!" on the screen. It's simple, but it proves everything is working.

The print() Function

To display output in Python, we use print():

python
print("Hello, World!")

Run this and you'll see:

text
Hello, World!

Let's break down what happened:

  • print is a built-in function—a command that Python already knows
  • The parentheses () contain what we want to print
  • The quotes "" mark the beginning and end of text (called a "string")
  • Python executed the instruction and displayed the result

Multiple Lines

Programs run from top to bottom. Each line is an instruction:

python
print("Line 1")
print("Line 2")
print("Line 3")

Output:

text
Line 1
Line 2
Line 3

Printing Numbers

You can print numbers without quotes:

python
print(42)
print(3.14159)
print(2 + 2)

Output:

text
42
3.14159
4

Notice that print(2 + 2) displayed 4, not "2 + 2". Python calculated the result first, then printed it.

Combining Text and Numbers

Use commas to print multiple things on one line:

python
print("The answer is", 42)
print("2 + 2 =", 2 + 2)

Output:

text
The answer is 42
2 + 2 = 4

Comments

Lines starting with # are comments. Python ignores them completely—they're notes for humans:

python
# This is a comment - Python ignores it
print("This runs")  # Comments can go at the end of lines too

# Use comments to explain WHY, not what
# Bad: Add 1 to x
# Good: Account for zero-indexing

Practice

Try these exercises:

  1. Print your name
  2. Print your age
  3. Print "My name is [name] and I am [age] years old" (use commas)
  4. Print the result of 100 * 365 (days in 100 years)
  5. Add comments explaining what each line does

Tags

hello-worldprintbeginnerfirst-steps
Related documentation