Home > Python > Difference between python and java

Difference between python and java

This post was most recently updated on August 2nd, 2024

Python does not have complex syntax and is one of the easiest language for any new programmer to start with. Below are some of the advantages of Python over Java.

1. Easy to Setup: To run a sample java program user needs to install and configure suitable jdk then download eclipse IDE.
In case of python, user just needs to install a suitable IDE. Any other installation or configuration is not needed.
If Linux system is used then user can run a python program from command line as python is inbuilt in Linux system.

2. Reduction in code size: Python language helps greatly in reducing the size of the code. If any sample program logic written in Java takes 4-5 lines for execution, then same code logic if written in python takes only 1 or 2 lines.
For example: Let us see ‘Hello World’ program in java and python language.

In Java:

In Python:

3. Dynamic allocation of value: In java if we want to assign integer value to a variable then we need to declare a variable of type integer, similarly if we require a float value or string value then variable of that types are required to declare.
In python, we can assign different types of values to same variable.
For example: Let us assign value of integer and string type to same variable.

In Python:

In Java:

4. Protection from Semi-colon: Most common error made by a new programmer is missing of a semi-colon at end of the statement. Python gives us the freedom from use of semi-colon at end of the statement. It is not compulsory for a programmer to give a semi-colon at end of the statement. However, if a semi-colon is given at end of the statement still it is ok, as python interpreter will not throw an error.
For example: let us write simple print statement in both languages with and without semicolon.

In python:

In Java

5. Saving user from use of brackets: Brackets are mostly reduced or not used in Python. This saves user from making common mistakes like forgot use of bracket at any important place which was required.
For example: Let us compare a sample program in java and python where brackets are not used.

In Java:

In Python:

 

This Article is TAGGED in . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">