Python syntax can be executed by writing code directly in the Command Line:
>>> print("Hello, World!")
Hello, World!
Or by creating a Python file (.py) and running it:
C:\Users\YourName> python myfile.py
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
Unlike many other programming languages, indentation in Python is required and is used to define a block of code.
Example:
if 5 > 2:
print("Five is greater than two")
Python will give an error if indentation is missing:
if 5 > 2:
print("Five is greater than two")
The standard indentation is 4 spaces.
if 5 > 2:
print("Hello")
print("World")
Python uses indentation to make code clean, readable, and organized.