Python Download, Installation And Python Hello World Program

By Sruthy

By Sruthy

Sruthy, with her 10+ years of experience, is a dynamic professional who seamlessly blends her creative soul with technical prowess. With a Technical Degree in Graphics Design and Communications and a Bachelor’s Degree in Electronics and Communication, she brings a unique combination of artistic flair…

Learn about our editorial policies.
Updated March 7, 2024

This video tutorial explains how to download and install Python on Windows and other OS. We will also write/run the Python Hello World program:

Python – which is commonly known to be an open-sourced, interpreted, object-oriented, high-level programming language is very easy to learn due to its dynamic and simple syntax.

It is very user-friendly and is most popular for its easy-to-use syntax and readable code. If you are beginning your career as a programmer, then Python can be an excellent choice.

Before starting your journey with Python, there are some basic necessities that you should be aware of, like installing, configuring, and running Python programs on a machine.

This tutorial will explain all about the features of Python along with the installation and setup process with simple examples for your easy understanding.

=> Check Here To See A-Z Of Python Training Tutorials

Python Getting Started

Python Video Tutorial: Download And Install

A Complete Overview of Python with Installation Process:

Features Of Python

Enlisted below are the various features of Python:

  1. Simple and Easy to Learn: Python is simple and easy to learn, read and write.
  2. Free and open-source: Python is a free and open-source software which means that a user can edit, modify or reuse the software’s source code. This gives the programmers an opportunity to improve the program functionality by modifying it.
  3. Interpreted Language: Python is an interpreted language, which means when we execute a python program, the interpreter executes the code line by line at a time. This makes debugging easy and thus is suitable for beginners.
  4. Python is Interactive: Interactive mode is a command-line shell that gives an immediate response for each statement.
  5. Portable: Python supports many platforms like Linux, Windows, MacOS, and Solaris.
  6. Object-Oriented: Python supports the Object-Oriented technique of programming which provides a means of structuring programs so that properties and behaviors are bundled into individual objects.
  7. Supports different programming models: Python supports procedure-oriented programming as well as object-oriented programming.
  8. Flexible: Python code can invoke C and C++ libraries and can be called from and C++ programs, and can integrate with Java and .NET components.

Python Installation And Set Up

The first step to start coding with any programming language is to set up the environment that will permit our code to run smoothly. Python can be installed in many ways.

The two most common ways are:

  • Download the official Python distributions
  • Using a package manager (Linux, macOS)

In this section, we shall cover installing Python on Windows, macOS, and Linux. Please, identify your Operating system, and let’s get started as below.

#1) Install Python On Windows 10

Unlike most Linux distributions, Windows doesn’t come shipped with Python. We have to install it by ourselves.

In this section, we shall cover the two common ways to install Python. But before we install, we should first check if Python is installed on our system or not.

Let’s open our terminal and run the following code.

python --version
# or
python3 --version

NB: On Windows, the terminal (Command Prompt) can be opened by clicking on the Windows key, then by typing “Command Prompt” and pressing Enter.

If the output shows a Python version, then Python has already been installed in your system. If the version is older than the latest, which is 3.9.1 as of now, then we will have to upgrade it.

However, if Python hasn’t been installed yet, then the warning message below will appear instructing us to run “python” without any argument in order to install Python via Microsoft Store.

Install Python on Windows

Install Python From The Microsoft Store Package

We will kick off with this way of installing Python because it is primarily intended for students and Python newbies. It was designed mainly for interactive use and it has some limitations that don’t make it suitable for professional use.

However, for most of us who are still beginners, this installation method is recommended.

Before opening the Microsoft Store app and searching for Python 3.9, we should make sure that we have the latest Windows 10 updates. We should also ensure that the Python we are selecting is published by the Python Software Foundation. Here is the warning from the Python official documentation.

Warning: Python will always be available for free on the Microsoft Store.
 If you are asked to pay for it, you have not selected the correct package.

As mentioned above, in order to get access to the Microsoft Store from the terminal, just run the following command without argument from the terminal.

python

Given below is the screenshot of the Microsoft Store App.

Microsoft Store
Microsoft Store App on Windows 10

Go ahead and select Python version 3.9 and follow the below instructions for installation. It should be approximately 34.81 MB.

This installation process also installs pip and IDLE alongside – this can be accessed by typing pip or idle on the command prompt or PowerShell.

Check That Python Was Installed

Same way, to check that our Python was successfully installed, we can find it in Start, or from the Command Prompt by running the below command.

python

Output

Check That Python Was Installed

Install Python From The Python Installer

As we saw above, installing from the Microsoft Store is mostly for students. However, for professional developers who want more control over the installation with a full-featured environment, using the Full installer is the right way.

All we need to do is download the official Python.exe installer and run it on our system.

Follow the below steps to download the full installer:

  • From a browser, navigate to Python.org’s page to download for Windows.
  • Select a Python version under “Python Releases for Windows”. As of now, the latest version is 3.9.1.
  • At the bottom, we can see different installers for both 64-bit and 32-bit systems. For a 32-bit system, we can only install the Windows installer(32-bit) while for a 64 bit, we can install the installer for both 32 and 64-bit. However, for a 64-bit system, the Windows installer(64-bit) is recommended.
Python Releases For Windows
Python Releases For Windows
  • Run the downloaded Python installer(assuming we downloaded Python 3.9.1).
  • Select the Install launcher for all users and Add Python 3.9 to PATH checkboxes as shown below.
Installation configuration
Installation Configuration

Note: Older versions of Python do not support the Add Python to Path checkbox option that merely helps to set the interpreter in the execution path for us. In case we have to set this manually, check here for instructions.

  • The last dialog will ask us to disable the path length limit. Disabling this will allow Python to bypass the 260 characters path length limit set by Windows. In the future, we shall definitely get to use the open() function and os module, and if we would want them to accept or return a longer path above 260 characters, then we should disable this option.
Disable Path Length Limit
Disable Path Length Limit

Note: Installing newer versions of Python will automatically install Pip and IDLE that can be accessed by running the commands pip and idle on the terminal.

To verify that Python was installed successfully, check as we did under the above heading “Check That Python Was Installed”.

#2) Install Python On macOS

macOS historically comes preinstalled with Python 2. But from Mac 10.15 and newer, this is no longer the case. Whatever be the case, it is recommended to install Python 3 because support for Python 2 ended as of Jan 1, 2020. More details can be found here.

Installing Python in MacOS can be done in several ways. The two most common ways are given below.

  • Using a package manager
  • Installing from the Python installer

The latter option is more reliable because a package manager like Homebrew, automates updates and allows us to switch between multiple Python versions with ease.

Using The Package Manager Homebrew

First, let’s check the section “Check That Python Was Installed” to identify what version of Python is installed on our mac. If it shows Python 2 or an older version of Python 3, then we should follow along, but the newest version is what we want.

Install XCode and its Command-line Tools

Before installing Python 3, we have to install Xcode which is necessary for most programming tasks. It will be used to install Homebrew.

Open a terminal and run the command below to install XCode and its command-line tools.

% xcode-select --install

NB: Do not include % while running the command-line code on Mac.

Install Homebrew

To install homebrew, open a terminal, and run the command:

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To confirm if Homebrew was installed successfully, run the command below that should display the version of brew installed.

% brew --version
# output
Homebrew 2.2.17
Homebrew/homebrew-core (git revision 62f3c; last commit 2020-05-23)

Install Python 3

Now, we can install Python with the simple command given below.

% brew install python3

To confirm that Python 3 is installed correctly, follow the instructions in the section “Check That Python Was Installed”.

From The Python Installer

In this section, we basically download the official Python installer from Python.org and run it on our system.

This method is preferred for programming GUI with Tkinter which is Python’s standard library for developing GUIs. This is because Installing with Homebrew doesn’t include the TCL/TK dependency that is required by the Tkinter module.

However, if we choose this method, we should be ready to go back to the website and download a new version each time we need to update Python.

Follow the below steps to install Python:

  • From a browser, navigate to Python.org’s page to download for macOS.
  • Select a Python version under “Python Releases for Mac OS X”. As of now, the latest version is 3.9.1.
  • At the bottom, click to download macOS 64-bit installer for either Intel or universal(suitable for both PowerPC and Intel machines).
python_release_Mac
Python Release for Mac OS X
  • Run the installer by clicking on the installer after it has been downloaded. This process will require a few clicks to continue until it successfully installs everything. Once that is done, click the Close button to exit the installer window.

#3) Installing Python On Linux

Linux has many distributions that we won’t cover in this tutorial. However, we will focus on the most popular distributions favored by most Python developers.

Though all distributions have equal capabilities to run Python code, they don’t officially support most of our favorite Python IDEs and toolchains. So, in this section, we will be looking at a distribution that is supported by the most popular and preferred IDEs that have a large user base.

In Linux, there are generally two ways to install Python:

  • Using a Package Manager
  • Building from source code

Using a package manager is the most common installation method and it is easy for beginners. However, some Linux distributions don’t have this tool and the only option is to build from source.

In this section, we shall look at installing Python on the Ubuntu distribution of Linux using its package managers. As of now, the latest version of Python is 3.9.1 and this version doesn’t come pre-installed in Ubuntu.

Installing Python On Ubuntu

Ubuntu is from the Debian family together with Debian, Linux Mint, etc. However, Ubuntu has the largest user base and all major IDEs are tested against it and supported.

Ubuntu has many release versions and installing Python may vary for each release. So, our first step will be to check the release version that we currently have.

Run the following command to check the Ubuntu release version:

$ lsb_release -a

Output

The output will be similar as shown below:

Ubuntu Release

We shall use deadsnakes PPA to install Python. But before that, let’s install some required packages:

Open a terminal and run the following commands:

$ sudo apt update
$ sudo apt install software-properties-common

On the same terminal(or new), run the below command to configure the deadsnakes PPA.

$ sudo add-apt-repository ppa:deadsnakes/ppa

After we have added the PPA, we can now update the apt cache and install Python 3.9

$ sudo apt update
$ sudo apt install python3.9

The final step is to check under the heading “Check That Python Was Installed” to make sure that Python was successfully installed.

Python Hello World

Mostly, newbies get to run their first Python code on Python’s interactive command line.

To get to the Python shell, we can open a terminal and run one of the commands:

$ idle
# or
$ python3

For a demonstration, let’s print the string “Hello World!” from the Python shell.

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

Though this is good for learning, it is not the proper way to write and run many lines of code as its code disappears when we stop the shell or close the terminal.

In Python, the module files are simply files that contain Python statements and as we shall see later, the modules can be imported into other modules and the Python’s interactive command line to gain access to its global variables, functions, and classes.

Example 1: In this example, we shall write an assignment statement in a file and save it with the name myfirst.py. Then import it into Python’s interactive command line and print the value of the variable.

NB: Module files are saved with the .py suffix.

Open an editor, paste the below code, and save it as myfirst.py

hell_var = "Hello World!" # assignment statement

Open a terminal in the directory where the file was saved and run the command to start the Python shell.

$ python3

Import the module into the interactive command line.

>>> import myfirst
>>>

Access the module’s defined variable hell_var

>>> myfirst.hell_var
'Hello World!'
>>>

NB: Notice how we accessed the variable using the dot notation(.) as it is a property of the module.

A Look At Python Configurations

Python interpreter recognizes many environment variables. However, we shall look at the most commonly used ones in this section. Most of the time, we shall have access to a ready-to-run Python environment. However, understanding these settings will help us to configure Python based on need.

The table below summarizes these Environmental Variables along with their description.

Environmental VariableDescription
PATHThis setting holds a set of directories containing executable programs. This is where the Operating system searches to run programs. This is where the Python interpreter will normally live.
PYTHONPATHThis setting is similar to PATH but serves as the container where Python searches for modules when they are imported in a program.
PYTHONSTARTUPThis setting contains directories to files of Python code that will execute automatically whenever we start our interactive interpreter. Whenever we are working interactively and we want to make sure some utilities are
loaded each time we start the Python interactive interpreter, This setting is the right place to handle it.

Project: Building A Simple Calculator Program

Enough with literature, in this section, we will build a basic calculator program that will request two numbers and add these numbers together.

This is no way close to a calculator but this example demonstrates how we can actually build something that is useful.

Open an editor and follow the below steps.

Request input

In Python, we use the input() built-in function to request the user input. In this stage, we shall request two numbers that we will then add together.

numb1 = int(input("Enter the first number: "))
numb2 = int(input("Enter the second number: "))

NB: We should note that the return value of the input() function is a string. So, we will have to convert it into an integer using int() for our addition to return the correct result.

Perform Addition

At this stage, we shall add the two numbers that we got from the user using the addition operator(+).

result = numb1 + numb2

Print The Result

Here, we are going to format an output that will be readable using the format string method.

print("{} + {} = {}".format(numb1, numb2, result))

Save the file as calc.py. Given below is the complete program.

while True: # repeat until it is stopped. 
    # Get user input
    numb1 = int(input("Enter the first number: "))
    numb2 = int(input("Enter the second number: "))
    # Add the numbers
    result = numb1 + numb2
    # print result
    print("{} + {} = {}". format(numb1, numb2, result))

NB: We used a while loop to keep the program running over and over requesting input and printing the computed result. We can end the program with Ctrl+z

Open a terminal where the file is saved and start the program by running the below command.

$ python calc.py

Enter the first number to add and press Enter. Do the same for the second number. The output below demonstrates how it looks like interacting with the program.

Print the result

Now, we have built a program that requests two numbers and returns their addition.

More About Python Installation

Python can be downloaded from its official site:

  • To download in your system go to the Download Python page and click Download Python.
  • Once the download is completed, open the .exe file and follow the on-screen instruction to install it.
  • Once Python is installed in your system, a graphical user interface program IDLE is also installed along with it to work with Python.

Follow the below steps to set path in windows:

Click on This PC or My Computer from your Desktop

MyComputer -This PC

Right-Click on This PC or My Computer

Python Installation - Step 1

Select Properties

Python Installation - Step 2

Click on Advanced system settings on the left side of the properties window

Python Installation - Step 3

Select Environment variables under the advanced tab

Python Installation - Step 4

Under System variables select the variable “PATH”

Python Installation - Step 5

Click on Edit

Python Installation - Step 6

Click on New

Python Installation - Step 7

Give the path of the location where Python is installed and click on OK

Python Installation Setup

My computer => Right click => Select Properties => Click on Advanced system settings => Select Environment variables under Advanced tab => Under system variables select the variable “PATH” => Click on edit => Click on New => Give the path of location where python is installed.

Once an Environmental variable is set successfully, we can check if python is installed correctly or not in the command prompt by simply typing “Python”.

Python Command

Basic Syntax

If you are familiar with another programming language, then you will be familiar with the curly brace and semicolon.

In Python, we need not worry about these two for statement separation and block of code separation. In python, everything will be indented.

Interactive Mode

Print (“Hello World”)

We can print the below statement in an interactive mode as mentioned in the below screenshot.

python interactive mode example

Script/Normal mode

#1) Open the editor in Normal mode.

#2) Write the statements that you want to execute.

#3) Save the file as filename.py

python script in normal mode

#4) Open the Command prompt.

#5) Go to the location where the file is saved.

#6) Now run the file as python filename.py as mentioned in the screenshot.

running the script in command prompt written in normal mode

Frequently Asked Questions

Q #1) How to install 64-bit python?

Answer: The easiest way is to use the Python installer. Navigate to the Python.org download page and choose the operating system you’ll like to install Python in. Then, select a release. As of now, the latest stable release is Python 3.9.1, and finally, navigate to the end of the page and download a 64-bit installer.

Q #2) Is Python free?

Answer: Python is an open-source programming language. Meaning, it is free and is available for most systems. Its community is huge with an awful lot of open-source libraries, frameworks, and packages that are available for use in various domains like Machine Learning, Artificial intelligence, Robotics, etc.

Q #3) Which Python version is best?

Answer: Python version 3 is the recommended version to use. Python has evolved since the first release of version 1 in 1994, then version 2 in 2000. However, due to some major improvement needed, Python version 3 was released in 2008.

Since then, both version 2 and 3 were highly used. Though version 3 was recommended, the two versions were maintained until 1st January 2020 while the maintenance for version 2 was dropped.

Q #4) Is Python 2 dead?

Answer: Python 2.x is officially dead. Maintenance for Python 2 was officially dropped on January 1st, 2020. Hence, it is recommended to use Python 3, and as of now, the latest stable version is 3.9.1

Conclusion

In this tutorial, we looked at how Python can be installed on various systems like Windows, Linux, and macOS.

We also looked at some commonly used configurations that can help us to set up our Python environment based on the need. We then had a shallow look at the modules and finally built a simple calculator program.

  • Python is a general-purpose programming language and if you are just beginning your programming career, then Python is a good option.
  • In Python, variables do not need a declaration to reserve the memory space. “Variable declaration” happens automatically when we assign a value to a variable.
  • Like any other programming language python also supports 6 standard data types which consist of both mutable and immutable features.
  • Numbers, string, and tuple are immutable data types whereas lists, Dictionaries and sets are mutable data types.
  • Python also supports 7 different types of operators and by using these operators we can perform various operations like Arithmetic, Comparison, Logical, Bitwise, Assignment, Identity, Membership on 2 or more operands.

PREV Tutorial | NEXT Tutorial

Was this helpful?

Thanks for your feedback!

Leave a Comment