Before Getting started with Python we need to download Python IDLE from Python web site.
How to download Python IDLE
- Open website https://www.python.org/ from your web browser.
- Click at Downloads. Different options will be shown. You can choose the version you want to download as per your operating system.
- We can click at all releases if we want to download an older version of Python.
Installing Python on your Windows based computer
- Double click at Python installer downloaded on your computer. Dialog box will appear as follow:
- Click close to close this window.
Note :- Now Python Install in our System. so Let's Start to use Python to Run a Program in the following Steps.
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
- Batch 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. Batch Mode/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 Batch/Script/Module/file
- After creating a Python batch/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: