First steps
Your first program
Goal: Print text and numbers · 6 min
A Python program is a sequence of instructions executed top to bottom. The function print() writes its arguments to the screen.
Text values are called strings and are written in quotes: "Hello" or 'Hello'. Numbers are written without quotes.
print accepts several arguments, separated by commas, and puts a space between them. After printing it starts a new line. Lines starting with # are comments — Python ignores them; they are notes for humans.
Worked example: Several arguments
print("Total:", 3 + 4)evaluates 3 + 4 first.- Then it prints both values separated by a space.
- Output:
Total: 7
# comment: ignored
print("Total:", 3 + 4)
print("3 + 4")Output:
Total: 7
3 + 4