This tutorial explains about Difference between Python 2.x and Python 3.x

Python 3. is the latest version released. 2.x is not supported now.

3 version is not backward compatible with the 2 version.

Difference between Python 2 and 3 version

Let’s see the differences

  • Shebang Comment.

It is a comment in your first line of a code, that tells to OS about the interpreter location to use for execution

For 2.x version, Shebang syntax is #!/usr/bin/python

#!/usr/bin/python
print "Hello "

#!/usr/bin/python3 is shebang comment for Python3 version

#!/usr/bin/python3
print("Hello")
  • IDLE Command

IDLE is a simple Python editor for writing and executing code

idle is a command to start the editor in 2. x version, whereas idle3 is a command to open in 3.x version

  • print command syntax. print command outputs the string into the output console.
  1. x version has a print command without braces.
print "Hello World"

3.x version has a print command with braces and string

print("Hello World");
  • pip command changes

pip is a package manager to manage third-party packages.

pip is a command in 2.x version To install and uninstall a package

pip install package
pip uninstall package

pip3 is a command in 3.x version

pip3 install package
pip3 uninstall package