Python Syntax
🧩 Python Syntax
Python syntax refers to the rules that define how Python code must be written and formatted. Python emphasizes readability and uses indentation instead of braces {} like other languages.
✅ 1. Python Code Execution
Python code is executed line by line (interpreted language).
Example:
✅ 2. Indentation (Very Important)
Python uses indentation (spaces or tabs) to define blocks of code—NOT curly braces.
Example:
🚫 Wrong syntax (no indentation):
✅ 3. Comments
Comments help explain code and are ignored by Python.
➤ Single-line comment:
➤ Multi-line comment:
✅ 4. Variables and Assignment
You don’t need to declare variable types.
✅ 5. Case Sensitivity
Python is case-sensitive.
✅ 6. Print Statement
Used to display output.
✅ 7. Multiple Statements on One Line (Not Recommended)
✅ 8. Line Continuation
You can break long lines using \:
✅ 9. Using Quotes
Python allows:
Triple quotes allow multi-line strings.
Quick Syntax Example
🎯 Summary
| Concept | Python Rule |
|---|---|
| Blocks of code | Defined by indentation |
| Comments | # or """ """ |
| Case-sensitive | Yes |
| End of line | No semicolon needed |
| Printing | print() |
