Info

In addition to key words, programming languages have operators that perform various operations on data. For example, all programming languages have math operators that perform arithmetic. In Python, as well as most other languages, the + sign is an operator that adds two numbers. The following adds 12 and 75:

There are numerous other operators in the Python language, many of which you will learn about as you progress through this text.

In addition to key words and operators, each language also has its own syntax, which is a set of rules that must be strictly followed when writing a program. The syntax rules dictate how key words, operators, and various punctuation characters must be used in a program. When you are learning a programming language, you must learn the syntax rules for that particular language.

The individual instructions that you use to write a program in a high-level programming are called statements. A programming statement can consist of key words, operators, punctuation, and other allowable programming elements, arranged in the proper sequence to perform an operation.

Compilers and Interpreters

Because the CPU understands only machine language instructions, programs that are written in a high-level language must be translated into machine language. Depending on the language that a program has been written in, the programmer will use either a compiler or an interpreter to make the translation.

A compiler is a program that translates a high-level language program into a separate machine language program. The machine language program can then be executed any time it is needed. This is shown in Figure 1-19. As shown in the figure, compiling and executing are two different processes.

jisrĀ® 1-19 Compiling a high-level program and executing it

GThe compiler is used to translate the high-level language program to a machine language program.

High-level language program

Machine language program

High-level language program

10100001 10111000 10011110 and so forth..

10100001 10111000 10011110 and so forth..

Machine language program

The machine language program can be executed at any time, without using the compiler.

10100001 10111000 10011110 and so forth..

Was this article helpful?

0 0

Post a comment