Understand Python and setup 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
- It has simple easy-to-use syntax.
- It can run on almost any platform including Windows, Linux's all distros(All versions of Linux), Mac OS X, Unix etc.
- You can even combine the pieces of other programming languages like C, C++, etc with python to utilize the best of both worlds.
- It's large standard library support makes real life programming much easier.
- Other than that, it's open source, and have a huge community support working actively with Python programming.
- It's Object Oriented (also called OO Programming or OOP) which makes it more applicable to be used in real world application programming.
- Also, it can not only be used to write complex programs but can also be used to design applications with GUI(Graphical User Interface).
- 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?
- 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 3.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.
- 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.
- 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.
- 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.
- AI and ML(Artificial Intelligence and Machine Learning): Python is at the fore front of the paradigm shift towards Artificial Intelligence and Machine Learning.
- 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:
- Go to python.org/download
- Download the latest release for Python 3.x for 32-bit or 64-bit depending upon your PC.
- Open Installer and follow these steps:
Click on Next, once you have checked the selected options in the window.
- Once these steps had been followed, the installation will begin.
- 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.
If you have a Macbook, the MacOS comes pre-loaded with Python 2.7.x but you cannot update the version or add module in pythona>, as its required by the operating system. So you should download Python 3 and setup virtual environment in Macbook.
If you use Ubuntu operating system, it comes pre-loaded with Python.