A statement is an executable Python instruction. Simple statements include assignments, function calls, print, pass, and del. A block contains one or more statements, usually separated by newlines. section 8.10
Python uses indentation to delimit blocks. Compound statements such as if-elif-else, while, and for contain clauses followed by indented blocks; compound statements can also nest inside other blocks. section 8.10
Keep these syntax rules in mind:
- Indent every statement belonging to a clause at the same level. section 8.10
- Use spaces consistently; mixing tabs and spaces can raise indentation errors. section 8.10
- Separate ordinary statements with newlines; semicolons can place multiple statements on one line, though this is usually poor style. section 8.10
- Use pass when a required statement should perform no action. section 8.1
A statement inside a conditional block
guess = 4 target = 7 if guess < target: print("Low") elif guess == target: print("Correct!") else: print("High") # Low section 8.1
Statements as a basic script
def main(): print("this is our first test script file") main() section 11.1
compound statement clause: block compound statement clause: block
Use this compact pattern to see how a compound statement pairs each clause with an indented block. section 8.10


