Skip to main content

A library to convert currency to words in Indian numbering system

Project description

Currency to Words (Indian System)

This is a Python package to convert numeric currency amounts into words, following the Indian numbering system.

Installation

You can install the package using pip:

pip install currency_to_words


from currency_to_words import convert_currency_to_words

amount = 1234567.89
print(convert_currency_to_words(amount))  # Output: One Lakh Twenty Three Thousand Four Hundred Sixty Seven Rupees and Eighty Nine Paise

Full Implementation with All Cases:

Here’s how you can implement the handling of these additional cases:

  1. Sentence case:

    • This format capitalizes only the first letter of the first word of the sentence and makes all the other letters lowercase.
    • Example: "One crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise"

    Logic: result[0].upper() + result[1:].lower()

  2. Alternating case:

    • This format alternates the case of each letter. The first letter is uppercase, the second is lowercase, the third is uppercase, and so on.
    • Example: "OnE cRoRe nInEtY tWo lAkH tHrEe tHoUsAnD fOuR hUnDrEd sEvEnTy EiGhT rUpEeS aNd nInEtY pAiSe"

    Logic: ''.join([char.upper() if i % 2 == 0 else char.lower() for i, char in enumerate(result)])

  3. Upper Camel Case (Pascal Case):

    • This format capitalizes the first letter of each word and removes spaces.
    • Example: "OneCroreNinetyTwoLakhThreeThousandFourHundredSeventyEightRupeesAndNinetyPaise"

    Logic: ''.join([word.capitalize() for word in result.split()])

  4. Lower Camel Case:

    • This format is similar to Upper Camel Case, but the first word starts with a lowercase letter, while the subsequent words start with uppercase letters.
    • Example: "oneCroreNinetyTwoLakhThreeThousandFourHundredSeventyEightRupeesAndNinetyPaise"

    Logic: words[0].lower() + ''.join([word.capitalize() for word in words[1:]])

Example Outputs:

  1. Uppercase: "ONE CRORE NINETY TWO LAKH THREE THOUSAND FOUR HUNDRED SEVENTY EIGHT RUPEES AND NINETY PAISE"
  2. Lowercase: "one crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise"
  3. Title Case: "One Crore Ninety Two Lakh Three Thousand Four Hundred Seventy Eight Rupees And Ninety Paise"
  4. Capitalize: "One crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise"
  5. Sentence Case: "One crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise"
  6. Alternating Case: "OnE cRoRe nInEtY tWo lAkH tHrEe tHoUsAnD fOuR hUnDrEd sEvEnTy EiGhT rUpEeS aNd nInEtY pAiSe"
  7. Upper Camel Case: "One Crore Ninety Two Lakh Three Thousand Four Hundred Seventy Eight Rupees And Ninety Paise"
  8. Lower Camel Case: "one Crore Ninety Two Lakh Three Thousand Four Hundred Seventy Eight Rupees And Ninety Paise"

Now the function can handle all the specified case formats. Just pass the desired case type as a parameter (case_type='uppercase', case_type='lowercase', etc.).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

currency_to_words-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

currency_to_words-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file currency_to_words-0.1.1.tar.gz.

File metadata

  • Download URL: currency_to_words-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for currency_to_words-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fa950d1f8aae930799357500b8ac8495ed234c9ff6f92f4eea62dfb5b765df7f
MD5 9208bf8c78355c0afd490ddf949a400c
BLAKE2b-256 4bea4b6a58ee2252d240fa90017d7796ba218535c9cc88b141c4984dc6ab95ef

See more details on using hashes here.

File details

Details for the file currency_to_words-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for currency_to_words-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7f92f98f78f27c3ddd214a7ae1be9d4b2fab3f14d53fb648b167aa8ca96a238
MD5 3017d84d6715ae268cb07b4093274e28
BLAKE2b-256 40e794c3538f17f5782dffd59b85ab89d23cb74334aa63a9e642d54d41fab7a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page