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:
-
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() -
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)]) -
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()]) -
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:
- Uppercase:
"ONE CRORE NINETY TWO LAKH THREE THOUSAND FOUR HUNDRED SEVENTY EIGHT RUPEES AND NINETY PAISE" - Lowercase:
"one crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise" - Title Case:
"One Crore Ninety Two Lakh Three Thousand Four Hundred Seventy Eight Rupees And Ninety Paise" - Capitalize:
"One crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise" - Sentence Case:
"One crore ninety two lakh three thousand four hundred seventy eight rupees and ninety paise" - Alternating Case:
"OnE cRoRe nInEtY tWo lAkH tHrEe tHoUsAnD fOuR hUnDrEd sEvEnTy EiGhT rUpEeS aNd nInEtY pAiSe" - Upper Camel Case:
"One Crore Ninety Two Lakh Three Thousand Four Hundred Seventy Eight Rupees And Ninety Paise" - 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa950d1f8aae930799357500b8ac8495ed234c9ff6f92f4eea62dfb5b765df7f
|
|
| MD5 |
9208bf8c78355c0afd490ddf949a400c
|
|
| BLAKE2b-256 |
4bea4b6a58ee2252d240fa90017d7796ba218535c9cc88b141c4984dc6ab95ef
|
File details
Details for the file currency_to_words-0.1.1-py3-none-any.whl.
File metadata
- Download URL: currency_to_words-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7f92f98f78f27c3ddd214a7ae1be9d4b2fab3f14d53fb648b167aa8ca96a238
|
|
| MD5 |
3017d84d6715ae268cb07b4093274e28
|
|
| BLAKE2b-256 |
40e794c3538f17f5782dffd59b85ab89d23cb74334aa63a9e642d54d41fab7a4
|