Download and install Python
Go to https://www.python.org/downloads/ and download the latest Python for your computer.
Assume that you use Windows, double click on the downloaded file and and follow the instructions to install Python for your computer. Check the “Add python.exe to PATH” to allow you to call python from any location when using the Windows command prompt.
Once the installation has been complete, you should have the following items added to your Start menu, e.g. mine are below:
Hello World
Open the Python IDLE (Integrated Development and Learning Environment). Type the following command and press Enter.
print("Hello World!")
You should see “Hello World!” printed on the screen:
Create a Python script file
You can use Python IDLE to create a Python script file. Below are the steps:
- On IDLE, click File -> New File (or press Contrl+N) to create a new python script file
- Add the command print(“Hello World!”) to the new file
- Save the file (File -> Save or press Ctrl+S) as hello.py at your desired location
Alternatively you can also use any text editor e.g. Notepad++ to create the above hello.py script
Run Python scripts from IDLE
You can use Python IDLE to run a Python script file. Below are the steps:
- On IDLE, click File -> Open (or press Contrl+O) to open a python script file
- On the script file editor (the newly open window), click on Run -> Run Modules (or press F5). The results are displayed on the IDLE window.
Run Python scripts from Windows Command Prompt
You can also run a Python script file from a Windows Command Prompt. Assume that the hello.py script file is at C:\Python\hello.py, execute the following command to run the Python script file.
py C:\Python\hello.py