Introduction to Python3

Python is a high-level general-purpose programming language. Python programs generally are smaller than other programming languages like Java. Programmers have to type relatively less and indentation requirements of the language make them readable all the time.

Note: For more information, refer to Python Programming Language

Introduction to Python3

  • Powerful, High-Level and Simple : Python( by Guido van Rossum , National Research Institute for Mathematics and Computer Science) is a powerful high-level programming language. The syntax is extremely simple to read and follow as it has a clean structure. Example: Python 3 has 33 keywords, and Python 2 has 31.
  • Interpreted Nature : Programs in many languages may be compiled or interpreted. Python has interpreted nature which means you just type in your code and run it, without the intermediate compilation step. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines, and then into another language (often machine code).
  • Popular Programming Language : It is being rapidly accepted and adapted by fortune organization. There are upcoming libraries in Python3 that support machine learning, data science, database manipulation, and Artificial Intelligence. Python is also one of the hottest skills to have and one of the most popular programming language in the world. In the last few years, it has been ranked as the number one most wanted technology of the year.
  • Free : Python is free to install, use, and distribute. There are different versions available for different Platforms. All Python releases are Open Source.
  • Portable language (cross-platform) Python language is also a portable language . Say, if we have python code for a platform like Windows, Linux or Mac, we can run this code on any other platform (which has Python interpreter installed) without changing it.
  • Object oriented : Python supports object-oriented language and concepts of classes and objects come into existence.

Difference Between Python2 and Python3

Python 3.0/Python 3000/Py3k is a new version of Python which is incompatible with the Python 2.x.(Python 2.0 was released in 2000).

Some of the major features that differ among the two are listed below !!

  • Print in Python: In Python2 , print is a statement while in Python3 print is a function that is conversion from no brackets to brackets !
    Example :
    In python2



    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    # syntax in Python2,
    # invalid for Python3
    print "Hello GfG !!"

    chevron_right

    
    

    In python3

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    # syntax for Python3 
    print("Hello GfG !!")

    chevron_right

    
    

  • Integer Division: Integer division in Python2 yields integer.

    Example: 3/2 will give 1 as an output!! (However, 3.0/2 or 3/2.0 will give 1.5 as the output).

    Integer division in Python3 can give a float value if required as per the answer.
    Example: 3/2 will give 1.5 as an output.

  • Compatibility: Python2 is easy to port to Python3. Backward compatibility is not possible in Python3 .
  • Performance: Python3 helps while typing whereas Python2 is not traditionally a typed language. Also, Python3 is faster in runtime execution than Python2.
  • Not equal to operator:
    Python2

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    a=1
    b=2
    print(a <> b)

    chevron_right

    
    

    Output:

    True

    Python3

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    print('GfG' != 'GfG')

    chevron_right

    
    

    Output:

    False
  • Exception:
    In python3, “as” keyword was introduced.
    Example:
    In python2,

    try:
       
    except valueError :
       

    In python3,

    try:
       
    except valueError as err:
       



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.