DEV Community

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

Posted on

2

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!!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay