Skip to content
Related Articles

Related Articles

Improve Article

Introduction to Python3

  • Last Updated : 12 Jan, 2021

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 Python 3

  • 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 30.
  • Interpreted Nature: Programs in many languages may be compiled or interpreted. Python has an 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 Python 2.x.(Python 2.0 was released in 2000). Some 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 a conversion from no brackets to brackets! 



Example : 

In python2 
 

Python




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

In python3 
 

Python3




# syntax for Python3
print("Hello GfG !!")
  • 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 the operator: 
    Python2 
     

Python




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

Output:
 

True

Python3 
 

Python3




print('GfG' != 'GfG')

Output:
 

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

Example: 
In python2,
 

try:
   
except valueError :
   

In python3,
 

try:
   
except valueError as err:
   

 

 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :