Skip to main content
Build Downloads Latest Version Supported Python versions License

Roman or Integer numbers can be converted into eachother an additionally representation of each one of them into binary format.

Installation

$ pip install RomanAlphabet

Usage

To represent an integer value into roman numeral system;

: from romanalphabet.romanalphabet import RomanAlphabet
: rr = RomanAlphabet("4785")
: rr.convert_to_roman()
: 'MMMMDCCLXXXV'

or into binary;

...
: rr.convert_to_binary()
: '1001010110001'

numbers can also be added or mutiplied into one another, as following; result could be three type of numeric format; “decimal”, “binary” or in “roman”;

: RomanAlphabet.addition("roman",1)
: 'I'
: RomanAlphabet.multiply("roman",1,2,3)
: 'VI'
: RomanAlphabet.multiply("decimal",1,2,3)
: 6
: RomanAlphabet.addition("binary",1,2,3)
: '110'
: RomanAlphabet.multiply("decimal",7,4,2,4,2,3)
: '10101000000'

If first argument not one of <code>decimal</code> <code>roman</code> <code>binary</code> then the following error will be displayed

: RomanAlphabet.multiply("deciaml",7,4,2,4,2,3)
---------------------------------------------------------------------------
InvalidInputError                         Traceback (most recent call last)
<ipython-input-6-bbd7bcac2f3a> in <module>()
----> 1 RomanAlphabet.multiply("deciaml",7,4,2,4,2,3)

/Users/denizci/.virtualenvs/RomanAlphabet/project/RomanNumbers/romanalphabet/romanalphabet.py in multiply(returned_base, *args)
    172         except TypeError:
    173             raise InvalidInputError, \
--> 174                 u"first input must be one of 'decimal', 'binary' or 'roman'"
    175         # Decimal multiplication is used for multipling one into another
    176         mutiplied = reduce(lambda x,y: int(RomanAlphabet(x).convert_to_int()) *\

InvalidInputError: first input must be one of 'decimal', 'binary' or 'roman'

Also roman numbers can be an input and represented with integer and binary format. If anything will goes wrong then for input as an example, none roman numerics if given then an understandable error will displayed.

: rr = RomanAlphabet("CVII")
: rr.convert_to_int()
: 107
: rr.convert_to_binary()
: 1101011
: rr = RomanAlphabet("MXXCVII")
---------------------------------------------------------------------------
InvalidInputError                         Traceback (most recent call last)
<ipython-input-4-928ae041fe2c> in <module>()
----> 1 rr = RomanAlphabet("MXXCVII")

/Users/barbaros/.virtualenvs/RomanAlphabet/project/RomanNumbers/romanalphabet/romanalphabet.py in __init__(self, input)
     21             if not result:
     22                 raise InvalidInputError, \
---> 23                         "Input has unqualified chars; '%s'" % message
     24
     25     @staticmethod

InvalidInputError: Input has unqualified chars; 'MXXCVII'
: rr = RomanAlphabet("CTII")
---------------------------------------------------------------------------
InvalidInputError                         Traceback (most recent call last)
<ipython-input-5-9cb900ee7522> in <module>()
----> 1 rr = RomanAlphabet("TVII")

/Users/barbaros/.virtualenvs/RomanAlphabet/project/RomanNumbers/romanalphabet/romanalphabet.py in __init__(self, input)
     21             if not result:
     22                 raise InvalidInputError, \
---> 23                         "Input has unqualified chars; '%s'" % message
     24
     25     @staticmethod

InvalidInputError: Input has unqualified chars; 'T'

Metadata

Release files for RomanAlphabet 1.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 RomanAlphabet 1.4
File Size Uploaded
RomanAlphabet-1.4.tar.gz 4.5 kB Details

Release files / RomanAlphabet-1.4.tar.gz

Download URL RomanAlphabet-1.4.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e5379befa8679fddefc7d709fcfb2a1e2621a49ee4416565f8af4c1372977177
BLAKE2b-256 checksum
How to use checksums
2c878b4823b5ff281c796e1f30ef67f0e8ea3017fd9cf8b9b397df84a47a02a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.4 This release

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.3

1 release file

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