Learnitweb

Features of Python

  • Simple – Python is a very simple language. Writing Python code is very simple and looks like writing English many times. However the rules of writing Python code are strict than English.
  • Easy to learn – Python is very easy to learn. Python has very less reserved words and are very much like English words. Learning Python is learning these words, their usage and some rules.
  • Freeware and open source – Python is free as well as open source. So you can read it’s source code, make changes to it, use it in your programs and freely distribute copies of this software. Python is based on the concept of community who takes care of Python and helps improve Python.
  • High level programming language – Python is a high level language. This means you need not to worry about how Python program interacts with processor, memory management, garbage collection and other low level details.
  • Platform independent – Python is platform independent. To work with Python you just need Python Virtual Machine. Same Python program can run on different platforms if Python Virtual Machine is available for that platform.
  • Portable – As Python is platform independent, this also makes Python programs portable. Python programs can be made to work on different platforms. Python programs can run on all common platforms like Linux, Windows, Solaris, Macintosh and many more. A program running on Windows can be ported to Linux without trouble.
  • Dynamically typed – Python is dynamically typed. To explain this let us see following code:
a = 10
print(type(a))
a = 'hello'
print(type(a))
a = '15.5'
print(type(a))

Output

<class 'int'>
<class 'str'>
<class 'str'>

In this code we assigned integer , string as well as float value to variable a. And we were able to do it successfully. We can see that type of variable also changed with every assignment. Such languages are also called Dynamically typed languages.

This is completely different from statically typed languages like Java. In Java we have to define the type of the variable at declaration itself. This declaration decides which type of values can be assigned to this variable and we can not change the type of the variable later in the program. For example:

int a;

Variable a is of type int and once declared, the type of variable can not be changed again.

  • Procedure-oriented and Object-oriented – Python provides features of both procedural programming as well as object oriented programming. In procedure-oriented programming programs are developed around functions and procedures. In object-oriented programming programs are developed around classes and objects. Python supports both programming paradigms.
  • Interpreted – Python is interpreted. So it also means it does not required compilation. You can directly run Python program from source code. This is in contrast to compilation where program is first compiled and then executed. You can read more about the difference between compiled language and interpreted language separately.
  •  Extensible – Python can work with different languages. For example, if there is some part of Python application where C/C++ is better to use for performance reasons then you can use C/C++ with Python code.
  •  Embedded – Python code can be used by other languages also. For example, Python code can be used with C/C++ programs.
  •  Extensive library – Python Standard Library is itself huge. Python has support for various things like mathematical calculations, file processing, networking, multi-threading, email, cryptography, database etc.