🧾 Python Syntax – Learn the Basics with TechTown

Welcome to TechTown.in, your gateway to mastering data and code! Today we dive into the basics of Python syntax—how Python code is written and why it’s famous for simplicity and readability.


🟢 Python Indentation

Python uses indentation (white space at the beginning of a line) to define code blocks.

if 5 > 2:
    print("5 is greater than 2")

✅ Output:

5 is greater than 2

❌ Wrong Example:

if 5 > 2:
print("This will cause an error")

Error: IndentationError: expected an indented block


🔤 Python Comments

Use # for single-line comments:

# This is a comment
print("TechTown is awesome!")  # This is also a comment

📄 Python Variables

No need to declare data types—Python is dynamically typed:

x = 5
y = "TechTown"
print(x)
print(y)

Output:

5
TechTown

🧠 Case Sensitivity

Python treats variables with different cases as different identifiers:

a = 10
A = 20
print(a)  # 10
print(A)  # 20

💻 Try Python Code Live Below!

Want to practice what you’ve just learned? Run Python code live in the browser with our built-in editor: