Python is one of the most popular and fastest growing programming language which is being used by many professionals such as Data Analysts, Data Scientist, Scientists, Accountants, Mathematicians, Software Engineers, Network Engineers and so on. Python is being used in various fields such as data analysis, machine learning, artificial intelligence, big data, Automation, development of web and mobile apps, testing, hacking and so on.
1. Easy: Python is easy to learn and understand
2. Expressive : Python was designed to be highly readable which uses English keywords frequently where as other languages use punctuation and it has fewer syntactical constructions than other languages.
3. Free and Open Source : Python is free and open source
4. High-Level : Python is a high level programming language
5. Portable : Python program written on one platform (Windows, Linux, Mac) can be executed on another platform without requiring to change any code.
6. Object Oriented : Python supports object oriented concepts
7. Extensible : Python modules can be written in other programming languages such as C, C++ etc.
8. Embeddable : Python is preferred in embedded system as it is simple and requires less coding
9. Interpreted and Interactive : Python programs are processed at run time by the interpreter, no need to compile the program before executing it. Python is also considered as interactive because using the python prompt we can interact with the interpreter directly to write programs.
10. Large Standard Library : Python has huge number of libraries
11. GUI Programming : Python provides libraries using which one can develop GUI applications
12. Dynamically Typed : User need not to worry about the data type as python will identify and set the data type. For example if you declare a=10 then a will be considered as an integer and if you declare a=10.0 then a will be considered as float.
a=10
print(type(a))
a=10.0
print(type(a))
Parameter | Java | Python |
Compilation | Java is a Compiled Language | Python is an Interpreted Language |
Static or Dynamic | Java is statically typed | Python is dynamically typed |
String operations | Offers limited string related functions | It offers lots of string related functions |
Learning curve | Complex learning curve | Easy to learn and use |
Multiple inheritances | Multiple inheritances is partially done through interfaces | It offers both single and multiple inheritances |
Braces vs. Indentation | It uses curly braces to define the beginning and end of each function and class definition | Python uses indentation to separate code into code blocks |
Portability | Any computer or mobile device which is able to run the Java virtual machine can run a Java application | Python programs need an interpreter installed on the target machine to translate Python code. Compared to Java, Python is less portable |
Best use for | Java is best for Desktop GUI apps, Embed Systems, Web application services, etc | Python is excellent for scientific and numeric computing, Machine learning apps, more |
Database support | Java offers stable connectivity | Python offers weak connectivity |
Writing comments in a program helps in understanding the program better as it provides the documnetation. Every programming language has its own syntax for identifying what is a comment. Any line which is commented will not be executed by the compiler. In python, a line could be converted to a comment by using either # symbol or write the statements within tripple quotes(either single tripple quote ''' some text ''' or double tripple quote """ some text """).
# This line is commented and won’t be executed
''' This would be a multiline comment
in Python that spans several lines and
describes your code, your day, or anything you want it to '''
""" This would be a multiline comment
in Python that spans several lines and
describes your code, your day, or anything you want it to """
#a2=10
print(a2) # This will generate NameError as the first line is commented