Saturday, December 28, 2024
Google search engine
HomeLanguagesPython Numerize Library

Python Numerize Library

Numerize is that library of python which is used to show large numbers into its readable format. It basically converts numerical format into the compact short format. There is no need to show how many zeroes are behind the number. It itself checks the numeric digits behind the coefficient and then provides output in the compact short form accordingly.
 

Key Feature

It enhances the understanding as there is no need to write a number of zeroes behind the number coefficient(also called as trailing zeroes).
Examples: 
 

1 -> 1
10 -> 10
100 -> 100
1000 -> 1k
1500 -> 1.5k
1000000 -> 1M
1000000000 -> 1B
1000000000000 -> 1T

Note: 
 

  • Here k represents thousand (i.e. coefficient will have 3 trailing digits ), M represents Million (i.e. coefficient will have 6 trailing digits), B represents Billion (i.e. coefficient will have 9 trailing digits)and T represents Trillion (i.e. coefficient will have 12 trailing digits). 
     
  • It will convert numerical numbers only up to 100T. 
     

 

Installing Library

To install this module type the below command in the terminal.
 

pip install numerize 

Example 1: 
 

Python3




from numerize import numerize
 
a = numerize.numerize(100)
print(a)
 
a = numerize.numerize(1000)
print(a)
 
a = numerize.numerize(1500)
print(a)
 
a = numerize.numerize(1000000)
print(a)
 
a = numerize.numerize(1123456)
print(a)
 
a = numerize.numerize(10000000000)
print(a)


Output: 
 

100
1k
1.5k
1M
1.12M
10B

Example 2: 
 

Python3




from numerize import numerize
 
 
# Here we can also get number upto
# any decimal place
a = numerize.numerize(1234567.12, 2)
print(a)
 
a = numerize.numerize(1247854, 4)
print(a)
 
a = numerize.numerize(12134.123, 3)
print(a)


Output:
 

1.23M
1.2479M
12.134K

 

RELATED ARTICLES

Most Popular

Recent Comments