(self, other: Union[int, float, Fraction])
Multiply two monomials and merge the variables
        in both of them.

        Examples:

            Monomial({1:1}) * Monomial({1: -3, 2: 1}) = (a_1)^(-2)(a_2)
            Monomial({3:2}) * 2.5 = (5/2)(a_3)^2
Multiply two monomials and merge the variables
        in both of them.
Multiply two monomials and merge the variables in both of them .
def __mul__(self, other: Union[int, float, Fraction]):
        """
        Multiply two monomials and merge the variables
        in both of them.

        Examples:

            Monomial({1:1}) * Monomial({1: -3, 2: 1}) = (a_1)^(-2)(a_2)
            Monomial({3:2}) * 2.5 = (5/2)(a_3)^2

        """
        if isinstance(other, float) or isinstance(other, int) or isinstance(other, Fraction):
            mono = {i: self.variables[i] for i in self.variables}
            return Monomial(mono, Monomial._rationalize_if_possible(self.coeff * other)).clean()

        if not isinstance(other, Monomial):
            raise ValueError('Can only multiply monomials, ints, floats, or Fractions.')
        else:
            mono = {i: self.variables[i] for i in self.variables}
            for i in other.variables:
                if i in mono:
                    mono[i] += other.variables[i]
                else:
                    mono[i] = other.variables[i]

            temp = dict()
            for k in mono:
                if mono[k] != 0:
                    temp[k] = mono[k]

            return Monomial(temp, Monomial._rationalize_if_possible(self.coeff * other.coeff)).clean()
def __mul__ ( self , other : Union [ int , float , Fraction ] ) : if isinstance ( other , float ) or isinstance ( other , int ) or isinstance ( other , Fraction ) : mono = { i : self . variables [ i ] for i in self . variables } return Monomial ( mono , Monomial . _rationalize_if_possible ( self . coeff * other ) ) . clean ( ) if not isinstance ( other , Monomial ) : raise ValueError ( 'Can only multiply monomials, ints, floats, or Fractions.' ) else : mono = { i : self . variables [ i ] for i in self . variables } for i in other . variables : if i in mono : mono [ i ] += other . variables [ i ] else : mono [ i ] = other . variables [ i ] temp = dict ( ) for k in mono : if mono [ k ] != 0 : temp [ k ] = mono [ k ] return Monomial ( temp , Monomial . _rationalize_if_possible ( self . coeff * other . coeff ) ) . clean ( )