Pesquisar aqui

quinta-feira, 18 de março de 2021

PYTHON vs JAVA SCRIPT - 2

🔸 Python VS JavaScript: Syntax

Now that you know what they are used for, let's see how they are written and the differences in their syntax.

We will cover the differences in their main elements:

  • Code Blocks
  • Variable Definitions
  • Variable Naming Conventions
  • Constants
  • Data Types and Values
  • Comments
  • Built-in Data Structures
  • Operators
  • Input/Output
  • Conditional Statements
  • For Loops and While Loops
  • Functions
  • Object-Oriented Programming

Code Blocks in Python and JavaScript

Each programming language has its own style to define code blocks. Let's see their differences in Python and JavaScript:

How Python defines code blocks

Python relies on indentation to define code blocks. When a series of continuous lines of code are indented at the same level, they are considered part of the same code block.

We use this to define conditionals, functions, loops, and basically every compound statement in Python.

These are some examples:

Use of indentation to define code blocks in Python

💡 Tip: We will see the specific differences between these elements in Python and JavaScript in just a moment. At this moment, please focus on the indentation.

How JavaScript defines code blocks

In contrast, in JavaScript we use curly braces ({}) to group statements that belong to the same code block.

These are some examples:


Sem comentários:

Enviar um comentário

Comente de forma construtiva...

Nota: só um membro deste blogue pode publicar um comentário.