How to Get Started Coding in Python

Python is an easy-to-learn programming language that’s has a philosophy that includes, “readability counts,” making Python a good choice as a first programming language.

Most programming languages encourage indentation as a best practice to help readers identify blocks of code. Python insists on four spaces of indentation after the first line of a block of code.

Python’s a general purpose language that’s platform independent. That is, you can run Python on Windows, Mac, Linux, or any other Operating System.

Python’s a high-level language, abstracting away much of the detail so you can focus more on solving problems rather than on the details of the hardware and operating system.

Installing Python

Here are instructions for installing Python on Mac OSX, Windows, and on Linux. You’ll likely want to learn Python on your local computer; then you’ll probably want to start using Python to help you manage and automate your VPS hosting.

Install Python on Mac OSX

Mac OSX has Python 2.x installed by default as it’s used to perform specific administrative tasks on your Mac. For this tutorial and in general, you’ll likely want to install 3.x the most recent version of Python.

Install the HomeBrew package manager

If you haven’t installed it yet, Home Brew is an excellent package manager for Mac OSX.

Open a terminal on your Mac then run this command to download and install HomeBrew.

$ ruby -e "$(curl -fsSL"

Then check the version of HomeBrew using this command.

$ brew --version

Next, use HomeBrew to install Python 3 on your Mac.

$ brew install python3

Set up a Virtual Environment on your Mac

You’ll likely want to set up a virtual environment in which to develop Python projects. A virtual environment separates a space within which you can create Python programs without affecting the rest of your computer.

$ mkdir Environments
$ cd Environments
$ python3.6 -m venv dev_env
$ source dev_env1/bin/activate

You’re now ready to start coding in Python.

Write a Hello World script

Start with a simple Hello World script. Using your favorite text editor, create a file called Enter the following into and save it.

print("Hello World!")

From the command line run

$ python

The script should return this.

Hello World!

Congratulations! You’ve written a Python script. You can build on this to learn Python and start creating useful scripts.

Install Python on Windows

For Windows, go to the download page then download and install Python for “all users.”

Next, go to the Start menu and type cmd in the search box. Run cmd.exe as Administrator.

Then, change directory to the directory in which you installed Python and run this command to set the system path to Python:

setx PATH "%cd%;%path%;"

Set up a virtual environment on Windows

Open up Powershell, which is the command line environment within Windows that you’ll use to create and run Python programs.

Set the execution policy scope to the current user.

$ Set-ExecutionPolicy -Scope CurrentUser

Powershell will then prompt you for the execution policy. Type the following:

$ RemoteSigned

Windows will prompt you asking if you want to change the execution policy. Anwer “y” for yes.

Install the Chocolatey package manager

$ $script = New-Object Net.WebClient
$ $script | Get-Member

Use the output to implement the method.

$ $script.DownloadString("")

Install Chocolatey by running this command.

$ iwr -UseBasicParsing | iex

To upgrade Chocatey (a command you may need in the future:

$ iwr -UseBasicParsing |

Install Python 3

$ choco install -y python3

Now, check what version you have installed. It should be 3.x (a version 3 variation such as Python 3.5.2)

$ python -V

Set up a virtual environment

$ mkdir Environments
$ cd Environments

Then run this command to create a virtual environment. For this example, the virtual environment’s called dev_env1, but you can name it anything you want.

$ python -m venv dev_env1

Your command prompt should look similar to this.

(dev-env1) PS c:\Users\You>

Install a simple editor and create your first Python script

Install nano or use your favorite editor.

$ choco install -y nano

Open nano (or your favorite editor) and type the following:

print("Hello, World!")
(dev-env1) PS c:\Users\You> python

The program should return just what you’d expect.

Hello World!

Congratulations, you’ve written your first Python program.

Install Python on Ubuntu

As always, first, make sure Ubuntu’s package manager’s up-to-date.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get clean all

Then check to see if Python’s already installed and which version is installed.

$ python3 -V

You may find that Python3’s already installed.

Python 3.5.2

Next, install the Python, package manager.

$ sudo apt-get install -y python3-pip

With pip, you can install Python packages with this command.

$ pip install package_name

Start by installing some development packages that you’re likely to find useful.

$ sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

Setting up a Virtual Environment

To isolate your Python scripts from the rest of your VPS, create a virtual environment. This will enable you to code Python without worrying about making a mistake and doing any damage to any other packages installed on your VPS.

First, install the Python3 Virtual Environment: python3-venv.

$ sudo apt-get install -y python3-venv

Next, create a virtual environment in which to learn and practice Python.

$ mkdir environments
$ cd environments
$ python3 -m venv dev_env1

Before you can use your new dev environment, you’ll need to activate it.

$ source test_env/bin/activate

Now, you can start coding Python!

Write Hello World!

You can install an Integrated Development Environment (IDE) to create and run Python programs, but for this introduction to Python, you can use any text editor to write Python scripts. For the rest of these lessons, it’s assumed you’re using your VPS. You can follow along as easily on your Mac or Windows machine.

With your favorite text editor, create a file called

On your VPS using vi or nano, you could create a file call Enter the following in the file.

print("Hello World!")

Note: Python does not use semicolons that other languages (such as JavaScript) use.

Save the file. Now enter the following to run your script.

$ python

Should return.

Hello World!

Congratulations, you’ve written and run the traditional “Hello World” as your first Python program. You can build on this first script to learn Python.

How to install and get started with Python on CentOS 7

>Update your system

$ sudo yum -y update
$sudo yum -y upgrade
$ sudo yum clean all

Install the Yum Utilities Package and CentOS Development Tools

$ yum install yum-utils -y

Then install the CentOS development tools.

$ yum install groupinstall development
$ Install IUS

IUS (Inline Upstream Stable) will ensure that you install the latest stable version of Python for CentOS.

$ Install Python 3
$ sudo yum -y install python36u

Install the pip Python package manager and python36u-devel

$ sudo yum -y install python36u-pip
$ sudo yum -y install python36u-devel

Create a virtual environment

To keep your development environment separate from the rest of your VPS, create a development environment.

$ mkdir environments
$ cd environments

Next, run this command to start a virtual environment.

$ python3.6 -m venv dev_env1

Next, activate your virtual environment.

$ source dev_env1/bin/activate

Create Hello World!

Using your favorite text editor, create a file called with the following line in it.

print("Hello World!")

It should return the following.

Hello World!

Congratulations, you’ve just created your first Python script on your virtual server. You’re now ready to build on this to develop useful Python scripts.


You’ve now installed Python on your local computer (likely Windows or Mac), and you’ve installed Python on your VPS.

A good next step with Python would be to create some scripts to automate some common tasks that you might perform manually. Python’s an excellent tool for automating routine tasks associated with VPS hosting.


Check out the top 3 Python hosting services:

$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
A2 Hosting
$2.99 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$0.90 /mo
Starting price
Visit Hostens
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing

How to Install the Django Web Framework on a Ubuntu 22.04 VPS

Brief description When building a website, similar components are required, and
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Create a Dynamic Web App with Django

Overview As a “batteries included” framework, Django
3 min read
Mark Armistead
Mark Armistead

Use Python to Automate Routine Tasks on Your VPS or Dedicated Server

Here we'll use basic knowledge of Python to teach you how to leverage the extrao
6 min read
Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan
Hosting Expert

Getting Started with the Flask Micro Web Framework

Flask is an extensible microframework, meaning it comes with a small set of core
4 min read
Mark Armistead
Mark Armistead
Author provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.