Learn/Python/1. Hello, output
Lesson 1 of 15
Sign in

Python, lesson 1

Hello, output

Every program needs a way to show you what it's doing. In Python that is the built-in print() function. Give it a value and it writes that value to the screen, followed by a new line.

Text in quotes is called a string. You can use single quotes ('hi') or double quotes ("hi"); they mean the same thing. Pick one style and stick to it.

Printing more than one thing

print() accepts several values separated by commas. It puts a space between them for you:

Two optional arguments change how the pieces are joined:

  • sep sets what goes between the values (a space by default).
  • end sets what goes after the last value (a new line by default).

Comments

Anything after a on a line is a . Python ignores it. Comments are notes for people reading your code, including future you.

2 exercises to try what you just read.

Exercise 1

Your first program

Press Ctrl Enter or Check to test your code.

Exercise 2

A date stamp

Press Ctrl Enter or Check to test your code.

#
comment

How a program runs

Python reads your file from the first line to the last and runs each statement in order. If a line has an error, Python stops there and prints a message called a traceback. Read it from the bottom up: the last line says what went wrong, the lines above say where.

Further reading

  • The Python Tutorial: An Informal Introduction
  • Built-in function print()

Write a program that prints exactly these two lines:

The program reads no input.

Print today's launch date in the form 2026-11-09 using one print() call with three separate values: "2026", "11" and "09". Then, on the next line, print Ready...go! using two print() calls, where the first one ends with ... instead of a new line.

Expected output:

print("Hello, World!")
print("Python runs one line at a time, from top to bottom.")
print("Total:", 42)        # Total: 42
print(3, "apples and", 5, "pears")
print("2026", "11", "09", sep="-")   # 2026-11-09
print("Loading", end="...")
print("done")                        # Loading...done
# This line is ignored
print("This line runs")  # a comment can also follow code
Hello, World!
I am learning Python.
2026-11-09
Ready...go!