(self, substitutions: Union[int, float, Fraction, Dict[int, Union[int, float, Fraction]]])
return Polynomial._rationalize_if_possible(ans)
Get the value after substituting
        certain values for the variables
        defined in substitutions.
Get the value after substituting
        certain values for the variables
        defined in substitutions.
Get the value after substituting certain values for the variables defined in substitutions .
def subs(self, substitutions: Union[int, float, Fraction, Dict[int, Union[int, float, Fraction]]]) -> Union[int, float, Fraction]:
        """
        Get the value after substituting
        certain values for the variables
        defined in substitutions.
        """
        if isinstance(substitutions, int) or isinstance(substitutions, float) or isinstance(substitutions, Fraction):
            substitutions = {i: Polynomial._rationalize_if_possible(substitutions) for i in set(self.variables())}
            return self.subs(substitutions)
        elif not isinstance(substitutions, dict):
            raise ValueError('The substitutions should be a dictionary.')
        if not self.variables().issubset(set(substitutions.keys())):
            raise ValueError('Some variables didn\'t receive their values.')

        ans = 0
        for m in self.all_monomials():
            ans += Polynomial._rationalize_if_possible(m.substitute(substitutions))
        return Polynomial._rationalize_if_possible(ans)
def subs ( self , substitutions : Union [ int , float , Fraction , Dict [ int , Union [ int , float , Fraction ] ] ] ) -> Union [ int , float , Fraction ] : if isinstance ( substitutions , int ) or isinstance ( substitutions , float ) or isinstance ( substitutions , Fraction ) : substitutions = { i : Polynomial . _rationalize_if_possible ( substitutions ) for i in set ( self . variables ( ) ) } return self . subs ( substitutions ) elif not isinstance ( substitutions , dict ) : raise ValueError ( 'The substitutions should be a dictionary.' ) if not self . variables ( ) . issubset ( set ( substitutions . keys ( ) ) ) : raise ValueError ( 'Some variables didn\'t receive their values.' ) ans = 0 for m in self . all_monomials ( ) : ans += Polynomial . _rationalize_if_possible ( m . substitute ( substitutions ) ) return Polynomial . _rationalize_if_possible ( ans )