Python Notes
Python is a simple, general purpose, high level, and object-oriented programming language. Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.
What is Python?
- Python is a general purpose, dynamic, high-level, and interpreted programming language. It - supports Object Oriented programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data structures.
- Python is easy to learn yet powerful and versatile scripting language, which makes it attractive for Application Development.
- Python's syntax and dynamic typing with its interpreted nature make it an ideal language for scripting and rapid application development.
- Python supports multiple programming patterns, including object-oriented, imperative, and functional or procedural programming styles.
- Python is not intended to work in a particular area, such as web programming. That is why it is known as multipurpose programming language because it can be used with web, enterprise, 3D CAD etc.
- Python makes the development and debugging fast because there is no compilation step included in Python development, and edit-test-debug cycle is very fast.
Python 2 vs. Python 3
- Python 2 uses print as a statement and used as print "something" to print some string on the console. On the other hand, Python 3 uses print as a function and used as print("something") to print something on the console.
- Python 2 uses the function raw_input() to accept the user's input. It returns the string representing the value, which is typed by the user. To convert it into the integer, we need to use the int() function in Python. On the other hand, Python 3 uses input() function which automatically interpreted the type of input entered by the user. However, 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 that works similar to Java iterator. The range() returns a list for example the function range(0,3) contains 0, 1, 2.
- There is also a small change made in Exception handling in Python 3. It defines a keyword as which is necessary to be used.
Python Features
- Easy to Learn and Use: Python is easy to learn and use. It is developer-friendly and high level programming language.
-
Expressive Language: Python language is more expressive means that it is more understandable and readable.Interpreted Language: Python is an interpreted language i.e. interpreter executes the code line by line at a time. This makes debugging easy and thus suitable for beginners.Cross-platform Language: Python can run equally on different platforms such as
Windows, Linux, UNIX and Macintosh etc. So, we can say that Python is a portable
language.Free and Open Source: Python language is freely available at official web address.The source-code is also available. Therefore, it is open source.Object-Oriented Language: Python supports object oriented language and concepts of classes and objects come into existence.Extensible: It implies that other languages such as C/C++ can be used to compile the
code and thus it can be used further in our python code.Large Standard Library: Python has a large and broad library and provides rich set of
module and functions for rapid application development.GUI Programming Support: Graphical user interfaces can be developed using Python.Integrated: It can be easily integrated with languages like C, C++ and JAVA etc.