Understanding Python's built-in data types as a JavaScript developer

In this article, I'll help you understand the built-in datatypes in Python from the viewpoint of JavaScript

By: Ajdin Imsirovic 26 March 2023

What data types exist in Python?

1. Numeric data types:

  • Integer (int): represents positive or negative whole numbers, without decimals.
  • Float (float): represents decimal or floating-point numbers, including scientific notation.
  • Complex (complex): represents numbers with real and imaginary parts.

2. Sequence data types:

  • String (str): represents a sequence of characters.
  • List (list): represents a sequence of values, which can be of different types.
  • Tuple (tuple): similar to lists, but once created, cannot be modified.

3. Mapping data types:

  • Dictionary (dict): represents a collection of key-value pairs.

4. Set data types:

  • Set (set): represents an unordered collection of unique elements.
  • Frozen set (frozenset): similar to sets, but once created, cannot be modified.

There are also other data types that are not built-in to Python but can be imported from external modules, such as numpy arrays and pandas dataframes.

Understanding Python’s data types as a JavaScript developer

1. Numeric data types

  • Integer (int) in Python is similar to the Number type in JavaScript, which represents positive or negative whole numbers, without decimals.
  • Float (float) in Python is similar to the Number type in JavaScript, which represents decimal or floating-point numbers.
  • Complex (complex) in Python represents numbers with real and imaginary parts, which is not available in JavaScript.

2. Sequence data types

  • String (str) in Python is similar to the String type in JavaScript, which represents a sequence of characters.
  • List (list) in Python is similar to the Array type in JavaScript, which represents a sequence of values, which can be of different types.
  • Tuple (tuple) in Python is similar to the Array type in JavaScript, but once created, cannot be modified. Tuples are also immutable, whereas arrays are mutable.

3. Mapping data types

  • Dictionary (dict) in Python is similar to the Object type in JavaScript, which represents a collection of key-value pairs.

4. Set data types

  • Set (set) in Python represents an unordered collection of unique elements, which is similar to the Set type in JavaScript.
  • Frozen set (frozenset) in Python is similar to the Set type in JavaScript, but once created, cannot be modified.

As far the difference between frozenset and tuple is concerned, this might need a bit more clarification. The main difference between frozenset and tuple in Python is that frozenset is an immutable set of unique elements, while tuple is an immutable ordered sequence of elements.

Feel free to check out my work here: