Skip to main content

NumberToWords Library Example

This example demonstrates how to use the aaqnumtowords library to convert numbers to words in both Persian and English languages.

Installation

First, you need to install the aaqnumtowords library:

pip install aaqnumtowords

Usage

Here is an example of using the library to convert numbers to words in both Persian and English.

from aaqnumtowords import NumberToWords

try:
    # Convert number to words in Persian
    converter_fa = NumberToWords(language='fa')
    print(converter_fa.number_to_words(123456789123456789123456789))  # Sample number in Persian
    
    # Convert number to words in English
    converter_en = NumberToWords(language='en')
    print(converter_en.number_to_words(123456789123456789123456789))  # Sample number in English
except ValueError as e:
    print(f"Error: {e}")

Explanation:

  • This code converts a very large number to words in both Persian and English.
  • If the input number is too large or invalid, a ValueError occurs, and an error message is displayed.

Output:

صد و بیست و سه کوادریلیون چهارصد و پنجاه و شش تریلیون هفتصد و هشتاد و نه بیلیون یکصد و بیست و سه میلیون چهارصد و پنجاه و شش هزار هفتصد و هشتاد و نه one hundred twenty-three quadrillion four hundred fifty-six trillion seven hundred eighty-nine billion one hundred twenty-three million four hundred fifty-six thousand seven hundred eighty-nine


Notes:

  • This code allows you to convert numbers into a readable format in different languages.
  • You can change the language of conversion as needed.

Release files for aaqnumtowords 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aaqnumtowords 0.0.4
File Size Uploaded
aaqnumtowords-0.0.4.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aaqnumtowords 0.0.4
File Interpreter ABI Platform
aaqnumtowords-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / aaqnumtowords-0.0.4.tar.gz

Download URL aaqnumtowords-0.0.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
44512e06dab9cb24a3adf0679622ec638dde7720aea8b9006be9463b2caaffc6
BLAKE2b-256 checksum
How to use checksums
ba78c761a0927fcfb66a8fd89c10d9eb89a961d09113d88f4a1bf5aaef0df51b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / aaqnumtowords-0.0.4-py3-none-any.whl

Download URL aaqnumtowords-0.0.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3988a6d0d51afa259b50fccfc773773c1220cfc012fa641b9088a3ff97855535
BLAKE2b-256 checksum
How to use checksums
f3f40a307df273af2609bea4f68fc08437390e32ba0ea03963446854f314d8df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page