Chapter 1 Introduction to Python
1.3 The Computer¶
The structure of a computer and the mechanism in which Python code is executed are illustrated in Fig. 1.4. On the bottom of the figure is the hardware computer, which is physically tangible. It consists of three main components: the central processing unit (CPU), the memory and devices. On top of the computer runs an operating system, such as Microsoft Windows, Linux and Mac OS. Operating systems connect computer hardware and software, providing basic interfaces to software programs for controlling the hardware. For example, the file system is an interface that operating systems provide for organizing data in the hard drive. Browsers, text editors, music players, and the vast majority of other application programs are managed by the operating system.
![Fig. 1.4 The structure of a computer](../_images/fig1-4.jpeg)
Fig. 1.4 The structure of a computer¶
As shown in Fig. 1.4, Python is an application program running on top of the operating system, just like a browser or a text editor. Its main function, however, is to execute generic Python code, rather than performing a specific task, which browsers and text editors do. On the top of the figure is Python code, which is executed by the Python application. Given a piece of Python code, or a Python program, Python executes it by interpreting the code into computer instructions, executed on computer hardware via the operating system.
© Copyright 2024 GS Ng.