Python Syntax and Order of Instructions
In Python, the order of instructions is important to ensure the correct execution of a program. Python follows a top-down approach, meaning the instructions are executed line by line, from top to bottom.
Basic Syntax Rules:
- Indentation: Python uses indentation (spaces or tabs) to define blocks of code (e.g., loops, functions, conditionals). Indentation is crucial and should be consistent throughout the code.
if True: print("This is indented") - Comments: Single-line comments start with
#, while multi-line comments use triple quotes ('''or""").# This is a comment """ This is a multi-line comment """ - Statements: Each instruction (statement) is typically written on a separate line. Multiple statements can be written on the same line by separating them with a semicolon (
;).x = 10; y = 20; z = 30