How Does a Computer Run a Python Program?

In order to understand what happens when you’re programming, it helps to have have a mental model of how a computer executes a program.

The computer is assembled from pieces of hardware, including a processor that can execute instructions and do arithmetic, a place to store data such as a hard drive, and various other pieces, such as a screen, a keyboard, an Ethernet controller for connecting to a network, and so on.

To deal with all these pieces, every computer runs some kind of operating system, such as Microsoft Windows, Linux, or macOS. An operating system, or OS, is a program; what makes it special is that it’s the only program on the computer that’s allowed direct access to the hardware. When ...

Get Practical Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.