No Semicolons, No Ceremony
Unlike many languages, Python doesn't need semicolons at the end of each line. It also doesn't require a main() function to run. Python scripts execute top-to-bottom, and you can start writing useful code immediately.
print("Hello")
print("World")
Try it Yourself โ
Indentation Is Law
In Python, indentation defines blocks of code. Instead of curly braces, you use spaces or tabs. This forces you to write clean, readable code. Most Python developers use 4 spaces per indentation level.
if 5 > 2:
print("Five is greater than two")
print("This is inside the if block")
print("This is outside")
Try it Yourself โ
Variables Without Type Declarations
You don't need to declare variable types in Python. Just assign a value and Python figures out the type automatically.
name = "Alice"
age = 25
height = 5.6
is_student = True
Try it Yourself โ
Comments
Use the # symbol to write comments. Comments are ignored by Python and are only for humans reading the code.
# This is a comment
print("Comments are useful")
Try it Yourself โ