Installing Python is not too difficult, and involves downloading the installer, running it, and perhaps configuring a few specific details. This process can be found in Appendix I. Once installed, there are a few variations that can be used with it, the simplest probably being the Python Graphical User Interface or GUI. If you are running Python on a Windows PC, look at the Start menu for Python and click a link named “IDLE (Python GUI),” as shown in Figure 1.1. Click on this and the user interface will open. Click the mouse in the GUI window so that you can start typing characters there.
Python can be run interactively in the GUI window. The characters “>>>” are called a prompt, and indicate that Python is waiting for something to be typed at the keyboard. Anything typed here will be presumed to be a Python program, or at least part of one. As a demonstration, type “1” followed by pressing the Enter key. Python responds by printing “1.” Why? When “1” was typed, it was a Python expression, something to be evaluated. The value of “1” is simply “1,” so that was the answer Python computed.
Now type “1+1.” Python responds with “2.” Python inputs what the user/pro- grammer types, evaluates it as a mathematical (in Python form) expression, and prints the answer. This is not really programming yet, because a basic two-dollar calculator can do this, but it is certainly a start.
IDLE is good for many things, but eventually a more sophisticated environment is needed, one that can indent automatically, detect some kinds of errors, and allow programs to be run and debugged and saved as projects. This kind of system is called an integrated development environment, or IDE. There are many of these available for Python, some that are expensive and some that are freely downloadable. The code in this book has been compiled and tested using PyCharm, but most IDEs are acceptable. It is largely a matter of personal preference. Basic PyCharm is free, but there is a more advanced version that costs a small amount of money.
An advantage of an IDE is that it is easy to type in a whole program, run it, find the errors, fix them, and run it again. This process is repeated until the program works as desired. Multiple parts of a large program can be saved as separate files and collected together by the IDE, and they can be worked on individually and tested together. A good IDE uses color to indicate syntax features that Python understands and can show some kinds of error while the code is being entered.
A program, just like any sentence or paragraph in English, consists of symbols, and order matters. Some symbols are special characters with a defined meaning. For example, “+” usually means add, and “-” usually means subtract. Some symbols are words. Words defined by the language, like if, while, and true, cannot also be also defined by a programmer – they mean what the language says they mean, and are called reserved words. Some names have a definition given by the system but can be reused by a programmer as needed. These are called predefined names or system variables. However, some words can be defined by the programmer, and are the names for things the programmer wants to use in the program: variables and functions are examples.
Source: Parker James R. (2021), Python: An Introduction to Programming, Mercury Learning and Information; Second edition.