The __abs__ method in Python

Python __abs__() Method

The __abs__() method in Python specifies what happens when you call the built-in abs() function on an object. For example, let’s call abs() on a negative number: Output: The result is the absolute value of the negative number, that is, the distance from 0. The important part here is to understand that calling abs(n) is […]

Python __abs__() Method Read More »

None in Python

Python None vs False

In Python, None is an object implemented by the NoneType class. In Python, None represents an absence of a value in a variable. In Python, None is what would be a null in other commonly used programming languages. Unlike the null in the other languages, Python’s None has nothing to do with values 0 or

Python None vs False Read More »

@symbol in Python

Symbol @ in Python

In Python, the “at symbol” (@) is used in two different contexts: Decorators. Matrix multiplication. Let’s take a more in-depth look at both of these. Decorators in Python The main use case of the symbol @ in Python is decorators. In Python, a decorator is a function that extends the functionality of an existing function or class.

Symbol @ in Python Read More »

Comma as a thousand separator in Python

How to Use Comma as Thousand Separator in JavaScript

To comma-separate thousands in a big number in JavaScript, use the built-in toLocaleString() method. It localizes the number to follow a country-specific number formatting. To separate thousands with commas, localize the number to the USA. To do this, pass the ‘en-US’ locale code as an argument to the toLocaleString() method. For example: Output: Alternative Approaches

How to Use Comma as Thousand Separator in JavaScript Read More »