Skip to main content

A module to represent numbers by their place value.

Project description

https://travis-ci.org/necessary129/NumRep.svg

Version: 0.0.1.1

This module provides a way to represent the place values in a given number, eg:
>>> a = NumRep(1234456789123)
>>> a
NumRep(Crores=123445,Lakhs=67,Thousands=89,Hundreds=1,Tens=2,Ones=3)
>>> a.crores
123445
>>> a.ones
3
>>> a.hundreds
1
>>> a.tens
2
>>> a.lakhs
67
And Every integer in the NumRep has a GetRep() method, which returns the Representation of the number itself, eg:
>>> a = NumRep(123456789)
>>> a
NumRep(Crores=12,Lakhs=34,Thousands=56,Hundreds=7,Tens=8,Ones=9)
>>> a.crores
12
>>> a.crores.GetRep()
NumRep(Tens=1,Ones=2)
>>> a.crores.GetRep().tens.GetRep()
NumRep(Ones=1)
You can also do arithmetic operations on them and then use GetRep(), eg:
>>> a = NumRep(123456789)
>>> a
NumRep(Crores=12,Lakhs=34,Thousands=56,Hundreds=7,Tens=8,Ones=9)
>>> (a.crores - 2).GetRep()
NumRep(Tens=1)
This raises TypeError when you give a non-number to it., eg:
>>> a = NumRep('notanumber123')
Traceback (most recent call last):
...
TypeError: Not a valid number
This class also provides an all() function, which gives you the real value of the given denomination, eg:
>>> a = NumRep(1234456789123)
>>> a.all('hundreds')
12344567891
You can also use the values specified in the module for all(), eg:
>>> a.all(CRORES)
123445

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

NumRep-0.0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

NumRep-0.0.1.1.linux-x86_64.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file NumRep-0.0.1.1.tar.gz.

File metadata

  • Download URL: NumRep-0.0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for NumRep-0.0.1.1.tar.gz
Algorithm Hash digest
SHA256 2e02c5e28c9271a7649a4b61e6217245df33abb2d01cf3f68000a3523e03e75a
MD5 ac1ed3e7a8bc2363b4baac785f77a83d
BLAKE2b-256 e42800c5f21f9e2e0d30094dc7e909b01b309623d335139a36aa6a04970d9fc8

See more details on using hashes here.

File details

Details for the file NumRep-0.0.1.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for NumRep-0.0.1.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 72cde1ee807c6cd0b25c7b33845f0633dc7e319ebb0030157dd6055ecdca288c
MD5 21e5bc47065049b9effc1d8f83ab6d63
BLAKE2b-256 6981cc1bbc2c9c4aff984c209e6c4e850a3da313c869ef2fdd9bfffe5eb17cc4

See more details on using hashes here.

Supported by

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