What is Python?

Python is a high level, dynamically typed and object oriented language. It was invented in 1989 by Guido van Rossum

Features:

  • Object Oriented
  • Dynamically Typed
  • Interactive
  • Interpreted and byte compiled
  • Batteries included

Versions of Python

  • Python 2.7.11 (Last supported release for the 2.x release of Python)
  • Python 3.5

This tutorial covers Python 2.7.

Setup

Installing Python

  • #### Linux ####

    • Most of the popular Linux distros come with Python pre-installed.
    • Try running python --version at the terminal and make sure the output is python 2.7.11 or similar.
    • If you don't have python installed on your system, download the tar ball from here and run following commands:
      • tar -xvzf Python-2.7.5.tgz
      • cd Python-2.7.5
      • ./configure
      • make
      • sudo make install
  • #### Windows ####

    • Download the apropriate installer for windows from here and run it.

Installing 3rd Party Python Packages

We first need to install pip which is the preferred tool for installing 3rd party Python packages.

  • #### Installing pip on Linux####

    • On Debian/Ubuntu run: sudo apt-get install python-pip
    • On Fedora: sudo yum install python-pip
    • For other distros you may try the following:

      curl -O http://python-distribute.org/distribute_setup.py
      python distribute_setup.py
      curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
      python get-pip.py
  • #### Installing pip on Windows####

    • Follow the instructions given here

Installing Jupyter

We will be using Jupyter Notebooks during the workshops and to follow along you should have it installed.

To install Jupyter on your system, run the following command:

pip install jupyter

Starting Python Shell

  • ### Linux/Mac OS X ### Open a terminal and run python

  • ### Windows ###

    • Open cmd and run python.exe

Running the above command will open up the interactive python shell where you can run and evaluate arbitrary python commands.

Writing your first byte of Python code

Let's write the customary hello world program. On the console write the following and hit Enter

Development Tools for Python

IDEs:

  • Eclipse with PyDev plugin
  • PyCharm from JetBrains
  • Vim -- with syntastic, pylint plugins
  • Or good old notepad/notepad++/gedit etc. :)