After installing Python IDLE, we can type and run Python commands Using Python IDLE.
How To Run Python Commands Using Python IDLE
- Click at start Menu-> All Programs-> Python 3.6 ->IDLE (Python 3.6 32 Bit). IDLE may be different depending upon the version of Python installed on your computer.
- Python IDLE will open as shown below
- This window is also called Python shell or Python prompt window. Python prompt appears as >>> (Triple greater than sign). It is also known as chevron. We can type Python statements here.
Ways to make Python programs
We can make Python programs in two modes:
- Interactive Mode
- Script Mode
1. Interactive Mode
In Interactive mode, we can directly type Python statements at Python shell and get output immediately. It is shown as follows:
We can use Python statements at >>> prompt to get output as given below:
print(“Hello”) statement has been written here to get output hello
The main drawback of Interactive mode is that we can’t save Python statements. So we need to type Python statements again if we want to get same output.
2. Script Mode
In script mode, we can save the Python statements in a file. Python statements written in this file will run consecutively one after another.
Creating a script/module/file
To create a Python script or file we need to follow following steps
- Click at File-> New File from Python IDLE as :
- A new window will appear as:
- We can type Python statements in this window as follows:
- Then we need to save the file with extension .py. We can click File->save or shortcut Ctrl+S to save the file as follows:
- On clicking File->Save following dialog box will appear.
- We can specify the file name as per our choice.
Running a script/Module/file
After creating a Python script or file we need following steps
- Click at File-> Open and select the Python script file you want to run. If it is already open you can directly jump to step 2.
- Click at Run->Run or Press function key F5 to run the script
- The output of the script will be displayed at Python shell as: