Fraction Calculator is a Python project designed to perform mathematical calculations on fractions. It allows users to perform addition, subtraction, multiplication, and division operations on fractions, providing results in fractional form. The project utilizes magic methods in Python for enhanced functionality and ease of use.
- Perform addition, subtraction, multiplication, and division operations on fractions.
- Display results in fractional form (e.g., 1/2) for better readability.
- Utilize Python's magic methods to enable natural and seamless operations on fractions.
- Easily integrate the Fraction Calculator into existing Python projects for fraction-related calculations.
- Python 3: Latest version of the Python, python 3 is used to build the application.
-
Clone the repository:
git clone https://github.com/your-username/fraction-project.git -
Change into the project directory:
cd fraction -
Install dependencies (if any):
pip install -r requirements.txt -
Run the project
-
Import the Fraction class from fraction.py: from fraction import Fraction
-
Create fractions:
frac1 = Fraction(1, 2)
frac2 = Fraction(1, 4) -
Perform operations:
result_addition = frac1 + frac2
print("Addition:", result_addition) # Output: 3/4
result_subtraction = frac1 - frac2
print("Subtraction:", result_subtraction) # Output: 1/4
result_multiplication = frac1 * frac2
print("Multiplication:", result_multiplication) # Output: 1/8
result_division = frac1 / frac2
print("Division:", result_division) # Output: 2/1 (integer division)
- Implementing mathematical operations on custom data types
- Using magic methods for operator overloading
- Enhancing user experience with intuitive design
- Inspired by the need for a simple and intuitive fraction calculator in Python.
- Built with love and dedication to the Python programming community.
This project is licensed under the MIT License - see the LICENSE file for details.


