Number readability with underscores in Python 3
Number readability with underscores in Python 3

Number readability with underscores in Python 3

Here is a neat trick for Python numeric values: you can improve readability of large numbers by using underscores as separators, like this:

caption taken from repl.it: https://repl.it/languages/python3

Underscores will be โ€œignoredโ€ by Python when interpreting the numerical value, but for the programmer, this is much more easy on the eye. And yes, it works for floats too. Here is the official link with more examples.

PS: You are always free to opt for the scientific notation of large numbers, especially those with trailing zeroes, which are pretty straightforward to read. However, I find this notation to be very useful for accounting and financial apps, where large numbers are common but rarely used in their scientific form.