# Introduction to Python Programming/Python Programming - Installing Python
## Chapter 2: Installing Python

Here in this chapter, I will tell you about installing Python on your local machine. There are two versions of Python available from the main Python website namely the Python 2.7.XXXX and Python 3.0.XXX. I prefer to use, teach Python 2.7.XXX versions. In this book, I will be talking, and writing about Python 2.7.XXX. What’s the difference, one may questions. There are differences between the two versions with syntax and a few other minor changes.
Coming to the question, which Python is right for you?
Python like any other open source software is a constantly evolving where the users from all over the world are contributing, making and updating features. There is a board of members that vote on a particular feature and decide whether the feature needs to be integrated or not. The documentation that acts as the supporting is constantly evolving at the same time. So decide on which one you want to use depending on your preferences and evaluations.
That said, it’s more than enough that you know one of these either versions, knowing one will make it a breeze to know the other versions. Just keep that in mind, and start talking Python.
After deciding which version of Python to learn, the first thing you need to do with Python is install it.

### 2.1. Installing version of Python

After you have decided which version of Python to learn, you need to install it. Linux and Mac OSX machines come with preinstalled Python packages so you need not worry about installing. Run the command terminal and type in the keyword python, and the machine will tell you if you have Python installed or not. Go figure that, Good luck with that!
Since I have only a Windows machine, I will guide you through installing Python on a Windows computer. Go figure
As a matter of fact, Windows does not come with Python pre installed. Go ahead and download the version of Python software that you want to use from the Python official website.
Installing Python from Python dot org
* Download the latest Python Windows installer by going to http://www.python.org/ftp/python/ and selecting the highest version number listed, then downloading the .exe installer.
* Double-click the installer, Python-2.xxx.yyy.exe. The name will depend on the version of Python available when you read this.
* Make sure that you have the administrative rights on the machine that you are working on.
* Step through the installer program.
* Some of the features can be removed from the installation in case you do not have enough space on your hard disk.
* Python will be installed with all the proper files and extensions.
* After the installation is complete, close the installer and select Start->Programs->Python 2.7->IDLE (Python GUI). You'll see something like the following, which is a sample shot from my machine:
I am assuming that you have the standard Python interpreter on the machine that you are currently planning to work on with.

### 2.2. The Interactive Shell

Once you have Python installed, there are different ways to run Python programs. On the shell interpreter, you can run commands and test how the flow of code goes. You can save the code that you have written and then run the file to obtain the output for the code that you have written.
Here, I will explain how to run simple code snippets on the Python interpreter.
You can fire up the Python shell interpreter in any of the following ways.

#### 2.2.1. Method 1:

Run the command interpreter by pressing the windows and the letter R. You will see a window open up like this.
Type in the letters cmd in the text box and you will see a screen like the one shown below in Figure 2.
Once at the command prompt, change into the directory where the Python executable resides. For example, on my local machine, I have the Python executable residing on C:\Python27\. So, I will go ahead and change into that particular folder by typing “cd C:\Python27” on the command prompt. Here’s what I see on my local machine. Once inside the folder Python27, type in python at the command prompt and voila! You’ll see the Python shell interpreter as illustrated in Figure 3.

#### 2.2.2. Method 2:

Now there is a second way on firing the Python shell interpreter and the following will explain how to do the same. Click on Start-> All Programs->Python2.7->Python IDLE and you’ll see the following shell interpreter as shown in Figure. 4.
Feel comfortable with these methods of firing up Python shell interpreter, I will talk about different other methods of firing the shell interpreter as and when the situation rises for the occasion. Here IDE stands for Integrated Development Editor, this is the Graphical User Interface (GUI) of the Python programming paradigm.
Apparently, there are users who use the Python shell interpreter like a calculator, but I still stick my own calculator on my local Windows machine.
There is one important operator that anyone needs to know which is the “=” operator also called the assignment operator. Variables can be assigned values using the assignment operator and Python will dynamically typecast the variable based on the value assigned to the variable.
Launch the Python interactive shell in whatever way works on your platform, and let's dive in with the steps shown here:
Example 1. First Steps in the Interactive Shell
Welcome to the Python party! Lets Python like we have never Python”ed before.

### 2.3. Kick starting with Python

There is another way to achieve printing “Hello World” like shown in the earlier sections. Store the value “Hello World” in a variable and then print the variable. The output of the print statement are followed by the outputs that they provide just below them
To write multiple lines, just add ‘\n’ character where you want to introduce the new line. Just follow the following example.

### 2.3.1. Printing variables

Variables can be printed in their forms and also the types they are cast into can also be printed using the print command. To print variables,
The above print statements focused on printing a single variable. However, a combination of different variables can be printed using a same single print command.
Before printing integer variables, they have to be converted to string type using the str when printing along with string variables.

#### 2.3.2. Getting text inputs

Obtaining input from the interpreter into the shell is done using the input command available. The syntax and the following statements highlight the use of input commands. Strings inputs have to be enclosed within quotes. Errors are highlighted in red.
However for ease of use, you can specifically instruct the Python interpreter to typecast the input into the type of variable you want to use the variable in. if you don’t specifically provide the typecast, Python interpreter will do the job of typecasting the variable.
Now that we have a fair idea of the print and the input commands, let’s write a simple Python program that will ask your name, age, location, and your job details and prints the same. On the Python interpreter, I opened a new file and wrote the following piece of code and saved it as file.py.
Further, I ran the program on the Python shell and obtained my first output for the same.
There you go, you just wrote your first Python program and ran it on the Python interpreter.