Page 50 - Information_Practice_Fliipbook_Class11
P. 50
Type the command 7+5 and press the Enter key. The interpreter executes the command by evaluating the expression
7+5 and displaying the result. As shown in Fig 2.5, a short description of the error is displayed in case of an erroneous
command. As Python interpreter provides feedback to the user interactively, we say that it is working in the interactive
mode.
Fig 2.4 Executing a Python instruction
While entering the next command, we forgot to write an operator between the operands 7 and 5. So, IDLE points out
a syntax error (Fig 2.5).
Fig 2.5 IDLE's prompt to Exiting
The Python Installer for Windows includes IDLE, by default.
2.5.2 Python Editor
To be able to save multiple instructions for future use in the form of a file (typically having a .py extension), we
use the Python Editor. To use the IDLE editor, follow the sequence of clicks: <File> <new>. A file containing Python
instructions is called a Python script or a Python program, and working with Python scripts is called working in the
script mode. To keep the Python script simple, we just type three instructions in the file:
The first line is an instruction for printing a line of exclamation marks.
The second line is an instruction to print a welcome message.
The third line is again an instruction for printing a line of exclamation marks.
Before proceeding further, let us note that the print() instruction is used to display the output produced
on the execution of a Python script on the standard output i.e., the monitor. The text to be displayed is enclosed
between the quotes (single quotes or double quotes). For example, in the first line, the text (also called a string)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! is enclosed between the single quotes as '!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!'. This string could also be expressed as: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!". However, in this book,
we prefer to use single quotes. It is pertinent to mention that the numerical values and numerical expressions are not
enclosed within quotes. We will learn more about print() in the upcoming chapters.
36 Touchpad Informatics Practices-XI

