python trick big numbers visualisation 1

python trick big numbers visualisation

S = 10_000_000_000


print(f'A big number is easyer to read like this {S:,}', #>>> 10,000,000,000
      'or like this {:,}'.format(S), #>>> 10,000,000,000
      'than as this',s) #>>> 10000000000

Here is what the above code is Doing:
1. We create a variable called S and set it equal to 10_000_000_000.
2. We print the value of S using f-strings.
3. We print the value of S using the format() method.
4. We print the value of S without any formatting.

The output of the code is:

A big number is easyer to read like this 10,000,000,000 or like this 10,000,000,000 than as this 10000000000

As you can see, the f-string and the format() method make it easier to read large numbers.

You can also use the f-string and the format() method to format floating point numbers.

For example, let’s say you want to format the number 1.23456789 so that it only has two decimal places.

You can do this by using the f-string and the format() method like this:

Similar Posts