5.1. Starting python, command line and programming mode

5.1.1. Starting up Python, the command line

In Microsoft Windows, start the python interpreter by selecting Start, Programs, Python 3.x, IDLE (Python GUI). This is the command line mode of Python. Type:

print(12 + 15) <Enter>
a = 12.5       <Enter>
b = 2.0        <Enter>
print(a * b)   <Enter>
print(a / b)   <Enter>

In this mode, only single statements can be entered. It is not possible to ask Python to execute a set of statements at once.

5.1.2. Executing Python scripts

Below is a Python script (or program).

print(12 + 15)
a = 12.5
b = 2.0
print(a * b)
print(a / b)

From the Python program, select File, New Window, and an ascii editor pops up. Copy-paste the python script from the table above in the editor window. Use File -> Save As to save the script in a separate directory (e.g. python_scripts) on your harddisk, using the filename intro.py.

Run the script by selecting Run from your Python program. Now, you have executed your first python program. The python interpreter has executed all statements in the script file, printing the three outcomes of the calculations given in the script.