What Python is and how it runs
Python is a programming language: a precise way of writing instructions that a computer can carry out. You write those instructions as plain text, and a program called the Python interpreter reads them and does what they say, one statement at a time. Python is popular because the text is short and readable, it comes with a large toolbox, and the same language covers web servers, data analysis, automation and AI.
A recipe and a chef
Your program is a recipe. The interpreter is a chef who reads it from the top, one step at a time, and actually cooks. If step 7 says "add the saffron" and there is no saffron, the chef stops at step 7 and tells you exactly which line was the problem. Steps 1–6 have already happened. Keep this picture: it explains both how Python runs and how its error messages work.
1. Your first program
print shows something on the screen. Text goes in quotes. Everything after # on
a line is a comment: a note for humans that Python ignores.
print("Hello, Python!") # text in quotes is a string
print(2 + 3) # Python can calculate
print("2 + 3 =", 2 + 3) # print accepts several things, separated by commas
A slightly bigger program already uses the ideas this course is built on: names, a list, a loop, and a decision.
prices = {"tea": 120.0, "rice": 85.5, "milk": 32.0} # a dictionary: item → price
cart = ["tea", "milk", "milk"] # a list of items
total = 0
for item in cart: # repeat for each item in the cart
total = total + prices[item]
print(f"Items: {len(cart)}, total: ₹{total:.2f}")
if total > 150:
print("Free delivery!")
Notice the indentation. The lines inside the for and the if are pushed right
by four spaces. In Python, indentation is not decoration: it is how you tell Python which lines belong
together. Lesson 06 covers it properly.
2. What happens when you run a program
Step 1 is why a missing bracket is reported before a single line runs, while a problem like dividing by zero
only appears when Python reaches that line. Here is a grammar mistake. The error message points at the
problem with a caret (^):
print("this line would run first")
print("missing a closing bracket"
3. Interpreted, compiled, and where Python sits
| Compiled ahead of time (C, Rust, Go) | Python | |
|---|---|---|
| How it runs | translated once into machine code, then run | compiled to bytecode on the fly, run by the interpreter |
| Speed of raw loops | very fast | much slower, but heavy work is usually done by libraries written in C (NumPy, pandas) |
| Types | usually declared and checked before running | checked while running (dynamic typing); optional type hints for tools |
| Feedback loop | edit → compile → run | edit → run; try things instantly in the REPL |
"Python" usually means CPython, the standard interpreter from python.org, written in C. Others exist (PyPy, MicroPython for small devices), but everything in this course is standard CPython.
4. Two ways to run Python: the REPL and scripts
The REPL (interactive)
Type python in a terminal and you get a >>> prompt. Each line runs as soon as you press Enter, and the value of an expression is shown automatically. Perfect for experiments.
A script (a .py file)
Save code in hello.py and run python hello.py. It runs top to bottom. Only what you print is shown. This is how real programs are run.
>>> 7 * 6 42 >>> name = "Asha" >>> name.upper() 'ASHA' >>> exit()
5. Which Python are you running?
import sys
import platform
print("Python", platform.python_version())
print("implementation:", platform.python_implementation())
print("is it at least 3.12?", sys.version_info >= (3, 12))
There is only one Python today: Python 3. (Python 2 reached end of life in 2020, so ignore any tutorial that
writes print "hi" without brackets.) A new 3.x version is released every October, and this
course needs 3.12 or newer.
6. Python's personality
A short poem ships inside Python itself. It explains the style you will see in this course:
import this
"Readability counts" and "There should be one obvious way to do it" explain a lot of Python's design. When two solutions work, prefer the one a colleague understands at first reading.
7. What people build with Python
| Area | Typical tools | On this site |
|---|---|---|
| Web back ends and APIs | FastAPI, Django, Flask | the FastAPI course |
| Data analysis and engineering | pandas, PySpark, SQL | the PySpark, SQL and Databricks courses |
| AI and machine learning | scikit-learn, PyTorch, the OpenAI SDK | the OpenAI SDK and AI Engineering courses |
| Automation and scripting | the standard library, requests, CLIs | this course's project |
| Testing and DevOps | pytest, Ansible, cloud SDKs | lesson 19 |
Non-technical summary
Python is a language for giving a computer instructions in text that reads almost like English. A program called the interpreter follows the instructions line by line. It is slower than some languages at raw number-crunching, but it is fast to write, easy to read, and has ready-made libraries for almost everything, which is why so many teams use it.
Recap
- The interpreter reads your code, checks its grammar, compiles it to bytecode, and runs it top to bottom.
- SyntaxErrors are found before anything runs; other errors stop the program at the failing line.
- Indentation groups lines into blocks. It is part of the language.
- The REPL is for experiments; scripts (
python file.py) are real programs.
Checkpoint
7 * 6 shows 42. In a script, the same line shows nothing. Why?