Python is counted among the most popular programming languages today. The availability of extensive support
libraries, user-friendly data structure and a vibrant open source community will further improve the popularity of the language and there is speculation that Python could replace Java in the next few years.

Java developers should consider learning Python as these are times when upskilling and reskilling has become the need of the hour. Here are the basics of Python for Java developers.

#1. End statements

To end a statement in Python, you don’t have to type in a semicolon. You can simply press [Enter] key. Semicolons are used to delimit statements if you wish to put multiple statements on the same line.

#2. Code blocks and indentation

The most distinctive feature of Python is the use of indentation to mark blocks of code. You need to indent each line of code in Python to indicate the block of code.

#3. String variables

You need to enclose characters in quotes to create string variables in Python. The programming language uses single quotes, double quotes and triple quotes to denote literal stings. The triple quoted strings will automatically continue across the end of line statement.

#4. Tuple variable

This is another important and useful variable type similar to list. It can contain heterogenous vales. Tuple is immutable and much like a static array. A tuple is fixed in size, which makes it easy to replace in Python. It is declared by using parentheses following the variable name.

#5. Operator precedence

Operator precedence is much like Java in Python as well. Arithmetic operations are valued first followed by the comparison operators. Logical operators are valued last in Python. In Python, comparison operators have equal precedence, they are valued in the left-to-right order.

#6. Dictionaries

In Python, dictionaries are the lists of key: value pairs. This is a powerful datatype to hold a lot of related information that can be associated through keys. Python dictionaries are alternative to the Map in Java but they contain both heterogeneous key and value.

© 2022 RS ITHub

Log in with your credentials

Forgot your details?