image
image
image

Installing Python

image

There are two ways that you can install Python:

1. Python can be downloaded directly from the project site, and then you can install the individual libraries and components you want.

2. You could also install and download a package, which will come with libraries already installed. One option would be to download Anaconda. You could also use Enthought Canopy Express.

The second method will give you a hassle-free installation, so it is the best option for beginners. The problem with doing it this way is that you will have to wait for the complete package to be upgraded, even if you just want to get the latest the version of one of the libraries. This wouldn’t be a problem unless you start performing cutting-edge statistical research.

After you have installed Python, you will find several options for picking your environment. There are three main common options:

1. iPython notebook, which is similar to markdown in R.

2. IDLE, which is the default environment.

3. Terminal or Shell based.

Picking your environment will depend on what it is that you will need. I recommend iPython Notebooks. It will provide you with a lot of amazing documenting features while you are writing your code, and you can run the code in blocks instead of line by line. For the rest of this chapter, I will be referring to iPython environment.

To start out with you can use Python as a calculator like this:

“ In [1]: 2 + 3

Out [1] : 5 “

Let’s go over a few notes:

Before we really get into the problem-solving aspects of Python, let’s step back a bit and make sure that you understand all of the basics. Conditional constructs, data structures, and iteration form the crux of all programming languages. When it comes to Python, it includes if-else, while-loop, for-loop, dictionaries, tuples, strings, lists, and so on. Let’s go through a few of these.