Difference between Python 2 and Python 3

A Side-by-Side Comparison!

Plus
Plus

An older version of Python introduced in 2000 with a focus on making programming easy to learn, but it lost its usage with the release of Python 3.

What is Python 2?

Plus

 - Python 2.3 – July 29, 2003      - Python 2.4 – November 30, 2004  - Python 2.5 – September 19, 2006  - Python 2.6 – October 1, 2008  - Python 2.7 – July 3, 2010

Versions of Python 2.X Series

Plus

A new version of Python  introduced in 2008 with a focus on eliminating redundancy in coding & providing a more user-friendly experience for new programmers.

What is Python 3?

Plus

 - Python 3.3 – September 29, 2012   - Python 3.4-March 16, 2014   - Python 3.5 – September 13, 2015   - Python 3.6 – October 2016   - Python 3.7 –June 2018

Versions of Python 3.X Series

Plus

 - Python 2 treats the "print" keyword as a statement, not a function.   - Python 3 treats "print" as a function, not a statement.

Comparison based on “Print” Keyword

Plus

 - When diving two integers, we get an integral value in Python 2.  Eg. 7/2 yields 3.   - When diving two integers, we get a floating-point value in Python 3. Eg. 7/2 yields 3.5.

Comparison based on Division of Integers

Plus

 - In Python 2, exceptions are enclosed in notations using the keyword "except".   - In Python 3, exceptions are enclosed within parentheses after the keyword "except".

Comparison based on Exceptions

Plus

 - Python 2 has "xrange()" function to perform iterations over a range of numbers.   - Python 3 introduces the "range()" function as an updated alternative to iterate over a range of numbers.

Comparison based on Iteration

Plus

Ready to uncover all key distinctions between Python 2 and Python 3?

Start discovering now....

Plus

Step Up Your Game with InterviewBit Web Stories

Don't miss out on the chance to upskill yourself with IntervewBit's engaging web stories.