How to Install Python 3 on Your ComputerLast Update : 27 Jun, 2022
In this tutorial, You will learn to install and run Python on your computer. And install Python on various types of operating systems like Windows, Mac, Linux, etc.
Installing Python on your computer is the first step to becoming a Python developer. Also, There are many ways to run your Python programming code on your computer. These ways are as follows.
Install Python Separately on Your Computer
The following steps show how You can install and run Python on your computer.
- Download the Python latest version from Python's official website.
- Run the installer file.
- Follow the steps to install Python during the Python install process.
- Check "Add Python to environment variables" - This will help you to interpret (run) your Python code anywhere on your computer.
- Choose the path where Python is needed to install.
Once you successfully finish the installation process, you can run Python on your computer.
Run Python Commands in Immediate Mode
Once we successfully installed Python and add PATH to your computer, Type the command python in CMD (command line) will invoke the interpreter in Python immediate mode. In immediate mode, we can directly type in Python code in CMD and press enter to get Python code output.
We can use Python immediate mode as a calculator. Try to type 10 + 10 and press enter. 20 will prompt as answer/output.
To exit from immediate mode, type quit() and press enter.
Run Python Commands in the IDE (Integrated Development Environment)
To write Python script files, We can use any text editing software such as Notepad, Notepad++, Atom, Sublime Text, Visual Studio Code, etc. We just need to save the Python script file with the extension of .py.
Integrated Development Environment (IDE) is software that provides very useful features for programmers in the application development process. Also, IDE can make a programmer's life a lot easier.
IDE provides features like syntax highlighting, code hinting, error checking, file explorers, etc.
However, When We install Python on our computer, an IDE named IDLE is also installed. We can use IDLE to run Python scripts on our computers. It's a good IDE for Python programming beginners.
When We open IDLE, an interactive Python Shell is opened. Now We can create hello.py as an example.
To create hello.py, First, create a new file (File > New File) with IDLE and save it with the .py extension.
In the following image, Write sample Python code in the file and save it. To run the script, go to Run > Run Module or simply click the F5 key.
Write first Python Program
Now we have already Python on our computer and running. We can write our first Python program.
Let's create a very first simple Python program of "Hello World". A "Hello, World!" is very commonly used by programming beginners as the first program of any programming language. It prints "Hello, World!" text on the computer screen.
Type the following Python code in any text editor or a Python IDLE and save it as hello_world.py.
Now, run the Python script file. Python program will print the following output on your screen.
Congratulations! You just wrote and run your first program in Python.
This is an easy task. Also, This is the beauty of the Python programming language.