A tool to convert numbers (int, float) into Persian words
Project description
num2fawords
This package provides functions to convert a number (int or float) to a Persian word form.
Usage
>>> from num2fawords import cardinal_words, ordinal_words
>>> cardinal_words(1984)
'یک هزار و نهصد و هشتاد و چهار'
>>> ordinal_words(1232)
'یک هزار و دویست و سی و دوم'
>>> ordinal_words(123)
'یکصد و بیست و سوم'
Obviously, cardinal_words is used convert to cardinal form and ordinal_words for ordinal from.
Use can also pass in floating point numbers:
>>> cardinal_words(19.75)
'نوزده ممیز هفتاد و پنج صدم'
This is the default setting. If you’d like to ommit the word “ممیز” from the output and use “و” instead of it, you can:
>>> import num2fawords
>>> num2fawords.MOMAYEZ # default value:
' ممیز '
>>> num2fawords.MOMAYEZ = ' و '
>>> num2fawords.cardinal_words(19.75)
'نوزده و هفتاد و پنج صدم'
Also some people prefer, for example, “صد و هفتاد” over its other form “یکصد و هفتاد”. This library uses the second form which is the form used on official Iranian banknotes. But it can be changed:
>>> num2fawords.cardinal_words(170)
'یکصد و هفتاد'
>>> num2fawords.SADGAN
['', 'یکصد', 'دویست', 'سیصد', 'چهارصد', 'پانصد', 'ششصد', 'هفتصد', 'هشتصد', 'نهصد']
>>> num2fawords.SADGAN[1] = 'صد'
>>> num2fawords.cardinal_words(170)
'صد و هفتاد'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
num2fawords-0.2.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for num2fawords-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a6f641ae7cf082eab7eea4cb440e395d7ed61cb9545ea963ce9f931f2cc4c82 |
|
MD5 | f13bc0c0986781b3f658d73e46a3a1bc |
|
BLAKE2b-256 | 1bf8cf7ce1b70da748b9a1424170551f547a0183a5d528825d8c417fbc793a21 |