DEV Community

Cover image for Making The Switch And Understanding The Syntax: JavaScript VS Python
Jessica Papa
Jessica Papa

Posted on

Making The Switch And Understanding The Syntax: JavaScript VS Python

Hey there, everyone! I just wanted to update you all on my boot camp progress. I made it to the third phase, but I gotta say, it's been a real challenge. I was starting to feel pretty confident with JavaScript and JSX, but now we're learning a whole new language!

So which language am I learning now you ask? Why Python of course! Python is a programming language popular among beginners and professionals. It was created to be easy to read and write, making it a great choice for people new to programming.

Let's start with the basics!

JavaScript: console.log is a method for debugging and logging with more flexibility in terms of concatenation and formatting.

Python: print is a built-in function with automatic spacing and newline characters.

Image description

Both print in Python and console.log in JavaScript are used for displaying output, but they have slight differences in syntax and behavior.

Variable Declarations:

JavaScript: Use the let, or const keywords to declare variables.

Python: Variables are created when assigned a value. No declaration is needed.

Image description

Indentation:

JavaScript: Indentation is not significant for code blocks. Curly braces {} are used to define blocks.

Python: Indentation is crucial for code structure. It uses consistent indentation, typically four spaces, to define blocks.

Function Syntax:

JavaScript: Functions can be defined using the function keyword or as arrow functions (() => {}).

Python: Functions are defined using the def keyword, followed by the function name and parentheses.

Image description

Conditional Statements:

JavaScript: Uses if, else if, and else for conditional branching.

Python: Same conditional keywords are used (if, elif, else) but without parentheses, and a colon:is placed at the end of each line.

Image description

These are just a few examples, Happy Coding everyone!!

Top comments (0)