Thursday, November 25, 2021

Introduction to Python in simple Terms by www.BlueTEXT.in

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. This course is designed for software programmers who need to learn the Python programming language from scratch.

Introduction to Python

Python is a high-level, interpreted, interactive and object-oriented scripting language that finds its application in many areas like -
  • Web scripting.
  • 3d Modelling (Blender).
  • Desktop Applications -` Games (Pygame).
  • Scientific usage (SciPy/NumPy).
Python source code is available under the GNU General Public License (GPL). There are two major Python versions, Python 2 and Python 3.

Python features

  • Open Source and Simple to use.
  • Very powerful and Ubiquitous.
  • Supports broad standard library.
  • Supports interactive testing and debugging.
  • Established interface with all major DB's.
  • Runs on a variety of hardware platforms.
Technical features of Python

  • Object-oriented (supports both functional and structured programming)
  • Dynamically and strongly typed
  • Whitespace delimited (Indentation)
  • Scripting language which supports large applications.
  • High-level dynamic data types and supports dynamic type checking
  • Automatic garbage collection
  • Interpreted makes compiler interact with a developer.
  • Easy integration with CC++COMActiveXCORBA and Java.

Python Implementations

CPython - Python implementation on standard C language.
Jython - Python implementation with Java virtual machine to blend with Java.
Pypy - Python implemented in Python and its Just-in-time compiler making it fastest.
Iron Python - for windows, which implements common runtime libraries to interface with. NET.

Difference between Python2 & Python3




Comparison Parameter Python 2 Python 3
Year of Release Python 2 was released in the year 2000. Python 3 was released in the year 2008.
“Print” Keyword In Python 2, print is considered to be a statement and not a function. In Python 3, print is considered to be a function and not a statement.
Storage of Strings In Python 2, strings are stored as ASCII by default. In Python 3, strings are stored as UNICODE by default.
Division of Integers On the division of two integers, we get an integral value in Python 2. For instance, 7/2 yields 3 in Python 2. On the division of two integers, we get a floating-point value in Python 3. For instance, 7/2 yields 3.5 in Python 3.
Exceptions In Python 2, exceptions are enclosed in notations. In Python 3, exceptions are enclosed in parentheses.
Variable leakage The values of global variables do change in Python 2 if they are used inside a for-loop. The value of variables never changes in Python 3.
Iteration In Python 2, the xrange() function has been defined for iterations. In Python 3, the new Range() function was introduced to perform iterations.
Ease of Syntax Python 2 has more complicated syntax than Python 3. Python 3 has an easier syntax compared to Python 2.
Libraries A lot of libraries of Python 2 are not forward compatible. A lot of libraries are created in Python 3 to be strictly used with Python 3.
Usage in today’s times Python 2 is no longer in use since 2020. Python 3 is more popular than Python 2 and is still in use in today’s times.
Backward compatibility Python 2 codes can be ported to Python 3 with a lot of effort. Python 3 is not backwards compatible with Python 2.
Application Python 2 was mostly used to become a DevOps Engineer. It is no longer in use after 2020. Python 3 is used in a lot of fields like Software Engineering, Data Science, etc.


Print:

  • Python 2 treats “print” as a statement rather than a function.
  • Python 3 explicitly treats “print” as a function.

Integer Division:

  • Python 2 treats numbers without any digits. (Output of expression 3 / 2 is 1, not 1.5). To get the result 1.5, you would have to write 3.0 / 2.0.
  • Python 3 evaluates 3 / 2 as 1.5 by default, which is more intuitive for new programmers.

List Comprehension Loop Variables: Common name for the variables that are iterated over in a list comprehension as a global variable get interchanged. This is fixed in Python 3.

Unicode Strings: By default Python 3 stores strings as Unicode unlike Python 2.

Raising Exceptions: Python 3 requires a different syntax for raising exceptions.

  • Python 2:raise IOError, “some error message”
  • Python3: raise IOError(“some error message”)

No comments:

Post a Comment