"""Module implements a Fraction class.""" class Fraction: """ Implements a Fraction class. The Fraction class represents fractions and supports the creation of Fractions and typical operations, like addition and subtraction, on Fractions """ def __init__(self, num, denom): """ Initialize an instance of the Fraction class. Args: num: The numerator of this fraction denom: The denominator of this fraction """ self.numerator = num self.denominator = denom def __add__(self, other): """ Add two fractions. Args: other: a reference to the second of the two fractions being added Returns: a fraction representing the sum of the two fractions being added """ new_denom = self.denominator * other.denominator new_numerator = ( self.numerator * other.denominator + other.numerator * self.denominator ) return Fraction(new_numerator, new_denom) def __str__(self): """ Generate the string representation of a fraction. Returns: a string representation of a fraction """ return str(self.numerator) + "/" + str(self.denominator)