Skip to content

Muawiya-contact/roman-to-integer-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Roman to Integer Converter (Python)

Convert Roman numerals to integers in Python using a clean and beginner-friendly approach.
This simple script demonstrates how to implement Roman numeral conversion logic using Python data structures and control flow.


πŸ“Œ Overview

Roman numerals are composed of the following seven symbols:

Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

Special Cases:

  • I before V or X (e.g. IV = 4, IX = 9)
  • X before L or C (e.g. XL = 40, XC = 90)
  • C before D or M (e.g. CD = 400, CM = 900)

βœ… Features

  • Converts valid Roman numerals (1 - 3999) into integers
  • Handles all subtractive cases
  • Clean O(n) algorithm
  • Beginner-friendly code
  • Can be integrated into larger Python projects

πŸš€ Usage

# Example usage
if __name__ == "__main__":
    converter = Solution()
    print(converter.romanToInt("XI"))  # Output: 11

πŸ“‚ Project Structure

roman-to-integer-python/
β”œβ”€β”€ roman_converter.py       # Main script
β”œβ”€β”€ test_cases.py            # (Optional) Unit tests
β”œβ”€β”€ README.md                # Project documentation
└── LICENSE                  # MIT or any license

πŸ“„ License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it for personal or commercial use.

πŸ‘¨β€πŸ’» Author

Muawiya Amir