Thursday, June 7, 2018

Python 2 Vs Python 3







Current Python Versions 

There are two major version of python, Python 2 and Python 3

Python 2 and Python 3 are quite different.

Python2.x is legacy, Python 3.x is the present and future of the language






Important Points

No backward compatibility
It would be dangerous to Port Python 3.x code in Python 2.x







Comparison

Python 2
Python 3
Division Operator work like C language
Example: 3/2 result will be 1
Division Operator work according to mathematics rule
Example 3/2 result will be 1.5
Syntax work on version 2
Example: print “ Hello”
print(“Hello”)
Syntax work on version 3
Example: only one will work
print(“Hello”)
Implicit str type is ASCII, explicit support for UNICODE Implicit str type is UNICODE
Range() and xrange() Only range() function
Exception Handling Keyword as is requird
raw_input() for reading strings, input() function reads data with filtering raw_input is no more exits, input() function work like raw_input()



Prev: History of Python             
Next: Installation of Python


Thank You Please Subscribe to get latest update and Comment below

References: 
Python.Org  Wikipedia





No comments:

Post a Comment

Google+ Followers