what is The difference between python 2 and python 3?

what is The difference between python 2 and python 3?

what is the difference between python 2 and python 3?

 

what is the difference between python 2 and python 3?

 

Python is a high-level programming language. there are a lot of versions of python. So, everyone asks about which version is useful or popular nowadays.


What is Python 3?


What is Python 3?

 

Python 3.x series start from December 2008.

Python 3.x is the current version. So, it is inconsistent with the 2.x route of releases.

Python 3 is not fully backward compatible with python 2.

This version can be released for to fixing problems that is exists in python 2.

In this version, Extra library can be developed. So, that is the reason python3 is popular nowdays.

 

History of Python 3.

  • Python 3.0  –  December 3, 2008
  •               3.1  –  June 27, 2009
  •               3.2  –  February 20, 2011
  •               3.3  –  September 29, 2012
  •               3.4  –  March 16, 2014
  •               3.5  –  September 13, 2015
  •               3.6  –  October 2016
  •               3.7  –  June 2018
  • Python 3.8  –  14 Oct 2019

What is Python 2?


What is Python 2?

 

Python 2.x version can be started in 2000.

It’s latest version is 2.7. It was released in 2010.

Python 2.x series is no longer development. So, the feature is added in python 3.x.

 

History of Python 2.

  • Python 2.0: 16 Oct 2000
  •            2.0.1: 22 Jun 2001
  •               2.1: 17 Apr 2001
  •               2.2: 21 Dec 2001
  •               2.3: 29 July 2003
  •               2.4: 30 Nov 2004
  •               2.5: 19 Sep 2006
  •               2.6: 1 Oct 2008
  •  Python 2.7: 3 July 2010

Python 2:


  1. Print function bracket optional.
  2. Prefix string with u to make Unicode string.
  3. The division of integers always returns an integer: 5/2=2 data read.
  4. raw-input() reads string.
  5. generator.next().
  6. input() evaluate.
  7. Released in 2000.
  8. The syntax of python 2 was comparatively difficult to understand.
  9. new range() -iteration.

Python 3:


  1.  In Print() function bracket are compulsory.
  2. String in Unicode by default.
  3. Division of integers may result in float: 5/2=2.5
  4. raw-input() not available.
  5. next(generator).
  6. input() always reads string.
  7. Released in 2008.
  8. The syntax is simpler and easily understandable.
  9. Range() -iteration.

Why should we use Python 2?


Python2 is an open-source version free.

If you are working on a project that depends on third-party libraries or s/w which not portable in python 3. So, in which we can use python 2.


Why should you use python 3?


It support AI, machine learning and data science.

Python3 will support a large python developer community.

Python 3 offers toolkit and libraries. So, that’s the reason the Python 3 version is popular.


Python 2  vs Python 3:


Examples:
Python 3:

def main():
print(“hello world”)
if__name__=”__main__”:
main()

Python 2:

def main():
print”hello world”
if__name__=”__main__”:
main()


Which python version to use?


According to me, python 3 is better than python 2. Because it involves an extra feature that is not presented in python 2.

That’s the reason python 2 won’t available after 2020.

python 3 is always advisable for a new developer to select python version 3.

To download python versions click here.


Key difference.


Python 3 syntax is simple or easily understand whereas python 2 syntax is difficult to understand.

Its default storing string is Unicode whereas python needs to define the Unicode string.

Python 3 variable value does not change whereas the global variable value of in python 2 changes.

 

Harsh

Hey Friends, Welcome to thetechbuddy. This blog is about technical or programming knowledge.

This Post Has 3 Comments

  1. Avatar
    Kadam

    Good information buddy 👍

  2. Avatar
    Biradar Pandurang

    Nice…

  3. Avatar
    Pangal Srushti

    Very good work…. Keep it up 👍👍

Leave a Reply