Getting familiar with Python as a JavaScript programmer

Hello JavaScript programmers let’s become a python programmer within the next 30 minute (Not really) :)

1. First Program in Python :

As in JavaScript we use console.log() function to print anything on terminal/console in python we have to use print() function .

2. Variable in Python:

like javaScript we don’t need to write data type to declare a variable , but unlike javaScript there is no special keyword to define a variable , just define a name , that’s it…

3. Concatenation in Python:

like javascript python also is + to concat string

4. String Formatting :

okay if you are familiar with C ,you will find some familiarity ,Python uses C-style string formatting to create new, formatted strings. The “%” operator is used to format a set of variables enclosed in a “tuple” (a fixed size list), together with a format string, which contains normal text together with “argument specifiers”, special symbols like “%s” and “%d”.

5 . List in Python :

Lists are very similar to arrays of javaScript

6 . Conditional Statement in Python :

in python in any kind of code block, python used indentation tab/4space instead of curry braces .

Bonus : one thing you have to keep in mind in python , lowercase boolean (true/false) is not valid , in python boolean will be capitalized (True/False)

7. for loop in ython :

As you used for in loop of javascript to traverse an array , here in python there is also a for in loop available, so we can use it to traverse a python list .

8. While loop in python:

Note : we can’t use increment/decrement operator in python insend we used addition and assignment operation .

9. Define function in Python :

As you already familiar with Python’s block syntax , just you have to remember your ES5 regular function and just instead of function keyword replace by def keyword that’s it you are good to go …

10 . Dictionaries in Python :

Okay you can match your most familiar JavaScript object to Python Dictionary . It’s key value pair like JS object :

You can get property value by square bucket notation

Deep heart JavaScript Lover from Bangladesh