Python's primary output mechanism. Unlike many languages, it's a built-in function, not a statement.
# Basic output
print('Hello, World!')
print(42)
print(3.14)
# Multiple arguments (space-separated)
print('Name:', 'John', 'Age:', 25)
# Custom separator and end
print('A', 'B', 'C', sep='-') # A-B-C
print('Hello', end=' ') # No newline
print('World') # Hello World
# f-strings inside print
name = 'Python'
print(f'Learning {name}!') # Learning Python!# This is a single-line comment
'''
This is a
multi-line comment
(or docstring)
'''
"""
Another multi-line
comment style
"""Note: Multi-line strings technically create string objects. Python ignores them if not assigned to a variable, making them work as comments.
Python uses whitespace indentation to define code blocks — NOT curly braces {}.
# ✅ Correct indentation (4 spaces — PEP 8 standard)
if True:
print('This is indented')
if True:
print('Nested indentation')
# ❌ WRONG — will throw IndentationError
if True:
print('Missing indent!')
# ❌ WRONG — mixed tabs and spaces
if True:
print('Tab here')
print('Space here') # TabError!Critical rules:
Python has 35+ reserved words that cannot be used as identifiers:
import keyword
print(keyword.kwlist)
# ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await',
# 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
# 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
# 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return',
# 'try', 'while', 'with', 'yield']
print(keyword.iskeyword('if')) # True
print(keyword.iskeyword('hello')) # Falseimport this
# Prints 'The Zen of Python' — 19 guiding principlesCreate a program that prints your name, age, and favorite language using print() with custom separators. Then print Python's keyword list count. Finally, write a properly indented if/else block that prints 'Pythonic!' if a variable is set to True.