Python 2 Vs. Python 3
The two versions of Python- Python 2 and Python 3 are the most widely used Python versions and there are many differences between these versions which are as follows:
Python 1 | Python 2 | Python 3 |
---|---|---|
Python 1 | The release year of Python 2 is 2000 | The release year of Python 3 is 2008 |
Python 1 | The syntax is more complex in this version than in Python 3 | The syntax is easy and simple |
Python 1 | By default, strings are saved in ASCII format in version 2 of Python | By default, strings are saved in UNICODE format in this version. |
Python 1 | In Python 2, Print is a statement. So, the syntax is print “hello” | In Python 3, Print is a function. So, the syntax is print (“hello”). |
Python 1 | Exceptions should be enclosed in notations in Python 2. | Exceptions should be enclosed in parentheses in Python 3. |
Python 1 | In python 2, while using variables inside a for-loop, their values do change. | In Python 3, the value of variables stays constant. |
Python 1 | Python 2 is not that popular after 2020 compared to Python 3 | Python 3 is a more popular version of Python and is being used for many purposes |
Python 1 | To perform iterations in Python 2, xrange() is used | To perform iterations in Python 3, Range() is used |