Lessons / Python / What is Python?

Python · 14 min

What is Python?

Python as a language, a runtime, and a way to express instructions clearly.

Language vs runtime

Python is both:

  1. A language — rules for writing instructions (syntax).
  2. A runtime — a program that reads those instructions and carries them out.

You write source code (plain text). The runtime turns it into actions: printing text, calculating values, talking to files, and so on.

print("hello")
Check yourself

What does the Python runtime do with your `.py` file?

Indentation is structure

Many languages use braces { } to group statements. Python uses indentation (leading spaces) to show which lines belong together — for example, the body of an if or a loop.

Mixing tabs and spaces, or guessing the indent, causes IndentationError. Pick 4 spaces per level and stay consistent.

for i in range(3):
    print(i)
print("done")
Check yourself

In Python, indentation is only cosmetic and never changes program meaning.

Check yourself

How many times does `print(1)` run in: `for i in range(3): print(1)` ?

Example: 3 · integer

Ready to prove it?

Start timed exam