How to install Python and Run Python Code

Python Basics Part-2:How to install Python and Run Python Code?

Install Python On Windows

Install Python On Windows

Python is called Cross Platform Language, meaning you can Install and run it on Windows, Linux, and Mac osX operating system very easily. Now I will show here the simple method of how to Install Python and Run Python on your own computer (Windows Operating system).

Installing and Running Python on Windows

Download Python by going to Python’s official site Download Python page and clicking on Download Python 3.10.6.

Once the download is complete, double-click the file and follow the instructions to install Python.

How to Install Python Step-1

How to Install Python Step-1

Click on Customize Installation and select all the options as below:

Install Python Step-2

Install Python Step-2

Now click on Next and select all the options as below.

Install Python Step-3

Install Python Step-3

Once the Python installation is complete, a program called IDLE will be installed along with it. It is basically a Graphical User Interface (GUI) through which you can run Python code.

Open IDLE and copy the following code and press Enter.

print ("Hello, World!")

You should see an output just like below:

Python IDLE Editor

Python IDLE Editor

IDLE GUI allows you to save and run Python code in a separate file. And for this you need to open a new file by going to File=>New File in IDLE GUI and save the new file with .py extension, just like below:

Save Python File in IDLE Editor

Save Python File in IDLE Editor

Now paste the following code in your file with .py extension.

print("Hello Python! I'm String from a file")

Then press F5 or click Run Module. Just like below:

Python Code Run In IDLE

Python Code Run In IDLE

Now you will see the result below:

Python Result from a file

Python Result from a file

Run Python code from the Windows Command Prompt

But apart from IDLE GUI, you can run Python code directly from Windows Command Prompt, for this, you need to go to your Command Prompt and need to write just python, just like below:

Python from Powershell

Python from Powershell

Now you can freely run the python code, see the below screenshot:

Run Python in Command Prompt

Run Python in Command Prompt

Like the IDLE GUI, you can run the Python file from the Command Prompt, and for this, you just need to access the location where you have saved the .py file with the DOS cd command, then type python fileName.py and enter. Check out the screenshot below:

Python File Run from a folder in command form

Python File Run from a folder in command form

Leave a Reply

Your email address will not be published.