Functionality | Python 3 | Python 2 |
---|---|---|
Release Date | 2008 | 2000 |
Function print | print is a function in Python 3. print("hello World") | print is a class in Python 2. print "hello World" |
Number 2**31 or greater | Stored in int. | Stored in long. |
Operator <> | Operator <> has been removed | Operator <> can be used. |
Division of Integers | Whenever two integers are divided, you get a float value | When two integers are divided, you always provide integer value. |
Function returns | Most of the function returns iterable objects and it's more memory optimized | Most of the function returns the built-in object . |
Character written in a file | Number of characters written to file is returned | Number of characters written to file is not returned |
User input | function raw_input was replaced with input in Python 3 | In Python 2, you have a built-in function raw_input() to take input from user |
Unicode | In Python 3, default storing of strings is Unicode. | To store Unicode string value, you require to define them with "u". |
Syntax | The syntax is simpler and easily understandable. | The syntax of Python 2 was comparatively difficult to understand. |
Rules of ordering Comparisons | In this version, Rules of ordering comparisons have been simplified. | Rules of ordering comparison are very complex. |
Iteration | The new Range() function introduced to perform iterations. | In Python 2, the xrange() is used for iterations. |
Exceptions | It should be enclosed in parenthesis. | It should be enclosed in notations. |
Leak of variables | The value of variables never changes. | The value of the global variable will change while using it inside for-loop. |
Backward compatibility | Not difficult to port python 2 to python 3 but it is never reliable. | Python version 3 is not backwardly compatible with Python 2. |
Library | Many recent developers are creating libraries which you can only use with Python 3. | Many older libraries created for Python 2 is not forward-compatible. |
This article is contributed by Aditya. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.