Start with Python | Installation On Windows and Linux.


Now we know some basics about the Python programming language. In this tutorial, we will start with essential practical Python learning. The tutorial is designed so that even a person with no programming knowledge can also begin to learn Python.

The first step is to install and set up a programming environment. In this tutorial, you will learn how to set up the environment on Windows and Linux operating systems. On Windows, the whole process is GUI-based, while on Linux, there is a command-line interface.

To start, first download Python from here. The following show how to install it.

How to Install and Use Python on Windows?

Installation of python on Windows
Start Python installation on Windows.

You need to download the Python installer first and save it. After double click on the installer, you will see the above screen. It has two options one is installed now, and another is for customized installation.

The first option is for the default installation with an installation path. While if you use another option, you can customize packages and the installation path too. But for simplicity, we will choose the Install Now option.

After a successful installation, you will see the below screen. To start the Python console, type Python in the start search box and click on Python.

Python Installation on Windows Success.
Python console

The black console appears in the interactive programming environment of Python. Here you can write the Python code and execute it. For example, if you want to add two numbers, print Hello World, etc.

Adding two numbers example –  Type 3 +5 after >>> and enter, you will see the output 8. Here 3 and 5 are the operands, and + is an operator.

Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> 3+ 5
8
>>>

Print “Hello World” using the print function.

>>> print("Hello World")
Hello World
>>>

How to run a Python program code from a file?

Till now, we have successfully executed a few lines of code in interactive mode. Where we write code on prompt and get output, but this is not the case with actual software development. The programmer writes programming code in a file and passes them to the interpreter as input.

Let’s write the print(“Hello World”)  in a text file using a text editor and save the file with the .py extension. In our example, the file name is HelloWorld.py. To run, on cmd, type “py FileLocation/HelloWorld.py

D:\Python Examples>py HelloWorld.py
Hello World

D:\Python Examples>

Alternatively, you can also use an IDE for software development, such as VsCode.

How to Install Python on Linux?

Linux is another famous operating system. It is mainly used to deploy heavy applications on servers. For demonstration, we are using Linux CentOs7 with 64 bits. The Linux machine is connected to the internet. Because of that, we can install any package or rpm using yum.

We will use the command line interface to conduct all operations after connecting the Linux machine via ssh using putty.

Check if Python is installed.

# python --version
Python 2.7.5
#

Yes, we have already installed Python. If not so, do not worry. You can use the following command to install Python.

# sudo yum install python

Create a HelloWord.py file using the VIM editor. Write line print(“Hello World – Linux”);. Save and close the file. Following are the steps to execute the program.

# python HelloWord.py
Hello World - Linux
#

Conclusion :

We have learned how to start programming using the essential Python environment. There could be other packages needed while working with Python e.g setuptools and PIP

These we will cover in another tutorial with details. Here covering may make it more complex to understand.