/roman-numerals-with-python

An implementation of Roman numerals in Python, made with the purpose of studying object-oriented programming as well as exploring dunder methods.

Primary LanguagePython

Roman Numerals with Python

An implementation of Roman numerals in Python, made with the purpose of studying object-oriented programming as well as exploring dunder methods in Python.

📜 The Roman Integer

There's a class called Roman which can receive either an integer or a string representing a Roman numeral (e.g. XVII). When printed, a Roman numeral is always going to be displayed in a Roman fashion. Other than that, it is a regular integer: it can perform sum, subtraction, multiplication and division with other Roman objects and integers.

Roman numerals are always integers. It can be used as an integer if the Roman object is converted with the int() function. Warning: there are no representations of the number 0 or of float numbers, so passing them as Roman numerals will raise exceptions or ignore decimal values.

💻 Requirements

The following setup was used to make the source code on this repository:

  • Windows 10
  • Python 3.8.10