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