Python code to find operation of two rational numbers
~This is the code for finding addition, subtraction, multiplication and division of two number~ from fractions import Fraction class Rational: def __init__(self,numerator,denominator): self.numerator=numerator self.denominator=denominator def Adding_R(self): x=self.numerator+self.denominator y=Fraction(x) print("\nThe addition of two rational number is:",x) print("a/b form is:") print ("%s = %s " % (x,y)) def Sub_R(self): x=self.numerator-self.denominator y=Fraction(x) print("\nThe subtrction of two rational number is:",x) pri...
Comments
Post a Comment