Python Syntax
Python syntax is designed to be clean and easy to read. Unlike many other languages, Python uses indentation to define code blocks, not braces. This forces you to write readable code.
Indentation
Indentation is not just for style; it tells Python which statements belong to a block. The standard is 4 spaces per level.
if 5 > 2:
print("Five is greater than two!")
# This print is outside the if block
print("Always printed")
Variables and Comments
Variables are created when you assign a value. No keyword needed. Comments start with `#`.
name = "Alice" # string variable
age = 25 # integer variable
# This is a comment
Variable Naming Rules
- Can contain letters, numbers, underscores
- Cannot start with a number
- Case-sensitive (`age` and `Age` are different)
- Use lowercase with underscores for readability (`first_name`)
Multiple Assignment
You can assign values to multiple variables in one line.
x, y, z = 10, 20, 30
Two Minute Drill
- Python uses indentation (usually 4 spaces) to define blocks.
- Comments start with `#`.
- Variables are dynamically typed; assign without a keyword.
- Names are case-sensitive and can contain letters, digits, underscores (cannot start with digit).
- Multiple assignment is allowed.
Need more clarification?
Drop us an email at career@quipoinfotech.com
