Difference between Python 2.x and Python 3.x

Introduction

Python is a high-level programming language which is easy to develop and integrate the systems more effectively. Python was introduced by Guido van Rossum in the year 1991. The main feature of python which distinguishes it from other programming language is its seamlessly easy syntax which is similar to the English language and the line of code is comparatively fewer than others.

Python now a days is very popular ad is used for web development, mathematics, system scripting, and software developments.

Python 2.x

Python 2.0 was introduced in the year 2000 which introduces features like Unicode, cycle-detecting garbage collector. It will officially come to end in 2020 that means no more security patches and improvements will be released. That will automatically move the customers to Python 3.x version.

Python 3.x

In upcoming days python 3 is wholly accepted, python 2 is legacy. Python 3.x comes with the additional features. The prime reason to use Python 3.x is it is compatible with the modern techniques like AI, data science. Powerful libraries and toolkits are introduced with this 3.x version.

Difference between Python 2.x and 3.x

Key comparisonPython 2.xPython 3.x
Print functionprint “Hello”print(“Hello”)
ExceptionIt should be enclosed in notations.It should be enclosed in parenthesis.
Unicode supportBy default, strings are stored as Unicode.By default, strings are stored as ASCII, to store strings as Unicode add “u”.

 

Iterationxrange() is used for iterationRange() is used for iteration.

 

Integer divisionThe division of integer gives integer value.

Example: expression 5/2 will give 2 whereas 5.0/2.0 will give 2.5.

The division of integer gives float value.

Example: expression 5/2 will give 2.5.

LibrariesOld libraries created for Python 2 are not forward compatible. You can port 2.x library to 3.x but it will be complex.Libraries are created strictly for Python 3.x.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.