Why Python, and the Two Ways to Run It
Quick answer What a programming language is, the features that made Python the school-level choice, and the difference between interactive mode and script mode.
A program is a set of instructions written for a computer to carry out a task. A programming language is the set of words and rules used to write those instructions. Python is a high-level language, which means it is written in words close to English rather than in the 0s and 1s the machine actually understands.
The computer cannot run English. A translator program converts your code into machine language. Python uses an interpreter — a translator that takes your program one statement at a time, converts it and runs it immediately. A compiler, used by languages such as C++, translates the whole program at once before running any of it. Python reports an error together with the line number where it was found, which is very useful while learning. A grammar mistake is reported before the program starts running; other errors stop the program at the line where they occur.
You should be able to list the features of Python. Learn these five:
- Simple and easy to read. The syntax uses ordinary words like
if,else,whileandprint. - Free and open source. It can be downloaded and used without paying, and its source code may be studied and modified.
- Interpreted. Statements are translated and executed one by one.
- Portable (platform independent). The same
.pyfile runs on Windows, Linux or macOS, provided Python is installed. - Rich library support. Ready-made modules exist for mathematics, graphics, files and much more, so you do not have to write everything yourself.
One more feature is worth stating because it is tested: Python is case sensitive. Marks, marks and MARKS are three different names, and Print is not the same as print.
Where you type your code. Most schools use IDLE, the editor that is installed along with Python itself. IDLE stands for Integrated Development and Learning Environment. Other editors exist, and different labs set up different ones, so describe what your school uses rather than assuming everyone has the same screen.
Interactive mode. When you open IDLE you see the Python shell with the prompt >>>. Type one statement, press Enter, and the result appears at once.
>>> 12 + 8
20
>>> print("Namaste")
NamasteNotice that in interactive mode, typing 12 + 8 alone displays the answer. That happens only at the >>> prompt. Interactive mode is useful for testing one line, checking an expression or trying an operator — but nothing you type is saved.
Script mode. Here you open a new file, type the complete program, save it with a .py extension, and then run the whole file. The output appears in the shell window. Script mode is what you use for any real program and for practical examinations, because the program is stored and can be corrected and run again.
# area.py — a program in script mode
length = 12
breadth = 5
print("Area =", length * breadth)What the examiner expects. In a "differentiate" question, give two clean contrasts: interactive mode executes one statement at a time and does not store the program, while script mode executes a saved .py file as a whole and the program can be reused. Do not merely say "one is fast and one is slow".
- Python is a high-level, interpreted, free, portable and case-sensitive language.
- An interpreter translates and runs one statement at a time; a compiler translates the whole program first.
- Interactive mode uses the >>> prompt, shows results immediately and saves nothing.
- Script mode runs a saved .py file as a whole and is used for practicals.
- IDLE stands for Integrated Development and Learning Environment.
- In interactive mode an expression alone shows its value; in a script you must use print().
