Introduction to Python and setting up Python Development Environment

Welcome! This is your first step towards learning Python programming language. Or, Do you know this language already and are here just to revise your concepts?. It doesn't matter which category you belong to because we will be teaching you Python, right from the basics.

An experienced programmer might have an advantage of picking up topics and lessons rather quickly, even though we recommend you to not to hurry through the topics, since Python, although being a normal programming language, carries some nice treats for programmers, and you would not want to miss those in the tutorials.

For all the noobs out there, there is nothing to worry. You should be happy that you have chosen the most amazing and simple tutorial to learn Python.


Why Python?

Python is considered as one of the most versatile programming languages. If you have even a little experience in programming, then you will soon notice the difference. Let's take a look at the features of Python.


Features of Python

  1. It has simple easy-to-use syntax.
  2. It can run on almost any platform including Windows, Linux's all distros(All versions of Linux), Mac OS X, Unix etc.
  3. You can even combine the pieces of other programming languages like C, C++, etc with python to utilize the best of both worlds.
  4. It's large standard library support makes real life programming much easier.
  5. Other than that, it's open source, and have a huge community support working actively with Python programming.
  6. It's Object Oriented (also called OO Programming or OOP) which makes it more applicable to be used in real world application programming.
  7. Also, it can not only be used to write complex programs but can also be used to design applications with GUI(Graphical User Interface).
  8. Python is an Inerpreted language, as its the Interpreter which executes the python code line by line, which makes it easier to debug. But it is a topic of never ending discussion that is Python compiled? Well, technically it is, from user written code to bytecode, and the bytecode is then sent to the Interpreter to execute it. Here is a good StackOverflow discussion over this: Is Python interpreted, or compiled, or both?
  9. Python has numerous implementations like CPython(The Standard implementation of python), Jython(Targeted for integration with java programming language) etc.

As far as its simplicity of syntax is concerned, let's see an example code. Consider a program where you want the user to enter something from the keyboard and you want to save that value in a variable. For C++, a popular programming language, here is how you will be writing it:

#include<iostream>
using namespace std;
int main(){
	int x;
	cin >> x;
    return 0;
}

For Core Java, another popular programming language, it will be:

import java.util.Scanner;
class Test{
	Scanner input = new Scanner(System.in);
	public static void main(String args[]){
		int x;
		x = input.nextInt();
    }
}

And in Python, it is (*drum roll*):

x = input()

No kidding. That's all it will take. No file importing, no curly braces, no semicolons and just one line. It's really not necessary to understand that code piece right now. It was just meant to demonstrate you that how Python can be a programmer's relief.

Another thing that can be noticed in above code is, in the case of C++ and Java user can only type any integer as the input to variable x, because we have declared value x as an integer by specifying the code: int x;. In case of Python, programmers don't have to explicitly specify the data type while declaring a variable, python's compiler will do that itself, based on the type of value assigned to the variable.


Few things about the course

To be precise there are currently two releases of Python that are available on their official website i.e., Python 2.x and Python 3.x. In this course we will be dealing with Python 2.x, the reason behind this is because it is ideal to learn Python 2.x first.

Python 2.x is legacy, Python 3.x is the present and future of the language

Python 2.x is what has been used in the programming world until recently when Python 3.x stable version was released. Hence, for beginners Python 2.x is more than perfect to use, because you will find plenty of resources for it on the Internet. Moreover, Python 3.x has a poor library support, as it is very new, which means we will have less options to find and use ready-made functions/libraries. Certainly, this is not suitable for a beginner, but you can shift to Python 3.x once you get a hold over Python programming. So, let's get started with Python 2.x.

Also, there is not too much difference between Python 3.x and Python 2.x, the major change is in the way how you print anything. It was just print in Python 2.x and in Python 3.x they made it print(), yes added the brackets.


Applications of Python

One can say, you can do almost anything with Python.

  1. Web Application: Python can be used to develop scalable and secure web applications. Frameworks like Django, Flask, Pyramid etc are amazing to design and develop web based applications.

  2. Computer Software or Desktop Applications: As python can be used to develop GUI too, hence it is a great choice for developing desktop applications. Tk is an open source widget toolkit which can be used to develop desktop applications with python. Kivy is another such platform.

  3. Scientific Computing Application: For its amazing computational power and simple syntax, python is used for scientific computing applications. Python libraries like SciPy and NumPy are best suited for scientific computations.

  4. AI and ML(Artificial Intelligence and Machine Learning): Python is at the fore front of the paradigm shift towards Artificial Intelligence and Machine Learning.

  5. Image Processing: Python is known for its image processing capabilities, which includes traversing and analysing any image pixel by pixel. There are numerous python libraries available for image processing, for example: Pillow, scikit-image etc.

Starting with something that you might already be using: Websites like Instagram, Reddit, Mozilla, have been developed using Python. There are various web frameworks like Django (most popular one) and Pyramid, based on Python, which can be used to develop modern web applications.


Installing Python

Steps to set up Python environment in your Windows system:

  1. Go to python.org/download
  2. Download the latest release for Python 2.x for 32-bit or 64-bit depending upon your PC.
  3. Open Installer and follow these steps:

    Installing Python steps in windows

    Click on Next, once you have checked the selected options in the window.

    Installing Python steps in windows

  4. Once these steps had been followed, the installation will begin.
  5. You can check whether the installation was successful by typing python -V in cmd. If it returns the Python version that you have installed, then congratulations you're all set.

    Checking installed Python version


Set Environment Variable

Windows users will also have to set the Environment Variable path with the location of python directory, where it is installed. To set the path variable:

  1. Right click on My Computer → Properties. Then in the left sidebar, click on the last option with Advanced system settings
  2. A new window will be opened, click on the button Environment Variable
  3. Then to add a new User variable, click on New
  4. Then write path as the variable name and copy the path of Python folder in the value.

    Setting python path variable

  5. And it's done.

If you have a Macbook or you are using Ubuntu Operating System, then you do not have to do anything, as Python comes pre installed with these operating systems.