About Python

What is Python?

Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.

The official introduction to Python is:

Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.

Python 2 vs. Python 3

A list of differences between Python 2 and Python 3 are given below:

  • Python 2 uses print as a statement

       example:print “value”
    

    On the other hand, Python 3 uses print as a function

      example: print(“value”)
    
  • Python 2 uses the function raw_input() to accept the user’s input.

On the other hand, Python 3 uses input() we can cast this value to any type by using primitive functions (int(), str(), etc.).

  • In Python 2, the implicit string type is ASCII, whereas, in Python 3, the implicit string type is Unicode.
  • Python 3 doesn’t contain the xrange() function of Python 2. The xrange() is the variant of range() function which returns a xrange object.

The range() returns a list for example the function range(0,3) contains 0, 1, 2.

It is used for:

  1. web development
  2. software development
  3. mathematics modeling
  4. system scripting

What can Python do?

  1. Python can be used on a server to create web applications.
  2. Python can be used alongside with software.
  3. Python can connect to database systems. It can also read and modify files.
  4. Python can be used to handle big data and perform complex mathematics.
  5. Python can be used for rapid prototyping, or for production-ready software development.

Why Python?

  1. Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
  2. Python has a simple syntax similar to the English language.
  3. Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
  4. Python runs on an interpreter system, meaning that code can be executed as soon as it is written.
  5. Python can be treated in a procedural way, an object-orientated way or a functional way.

Features of Python

Simple

Python is a simple. Reading a good Python program like reading English. This pseudo-code nature of Python is one of its greatest strengths. It allows you to concentrate on the solution to the problem rather than the language itself.

Easy to Learn

You will see that Python is extremely easy to get started with. Python has a very very simple syntax.

Free and Open Source

Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use.

High-level Language

When you write programs in Python, you never need to bother about the low-level details such as managing the memory used by your program, etc.

Portable

Due to its open-source nature, Python can work on many platforms. All your Python programs can work on any platforms without requiring any changes but be careful about any system-dependencies. You can use Python on GNU/Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion.

Interpreted

Python converts source code written by the programmer into intermediate language which is again translated into the native language / machine language that is executed. So Python is an Interpreted language. - It is processed at runtime by the interpreter. - The program need not be compiled before its execution.

Object Oriented

Python supports procedure-oriented programming as well as object-oriented programming. In procedure-oriented languages, the program is built around procedures or functions which are nothing but reusable pieces of programs. In object-oriented languages, the program is built around objects which combine data and functionality. Python has a very powerful but simplistic way of doing OOP, especially when compared to big languages like C++ or Java.

Extensible

If you need a critical piece of code to run very fast or want to have some piece of algorithm not to be open, you can code that part of your program in C or C++ and then use it from your Python program.

Embeddable

You can embed Python within your C/C++ programs to give scripting capabilities for your program’s users.

Extensive Libraries

The Python Standard Library is huge indeed. It can help you do various things involving regular expressions,documentation generation, unit testing, threading, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, cryptography, GUI (graphical user interfaces), and other system-dependent stuff.