# Fraction Module:

This is a module which supports for rational number arithmetic. It creates a Fraction instance from numbers, floats, integers, strings, and decimals. Fraction has great significance in python and in the field of data science.

###### Fraction Instances –

A pair of integers construct it, another rational number or a string. These instances are hashable in nature, and they are immutable.

1. Class fractionsFraction(numerator=0, denominator=1): In this, it’s the necessesity that the numerator and the denominator are instances of numbers. So, fraction instance and a rational with value = (numerator/denominator) is return. In case the denominator is zero, a zerodivision error is there. 1. class fractionsFraction(other_fraction): It’s the necessasity the other_function is instance of numbers. So, rational and fraction instance with equal values is in return.
2. class fractions.Fraction(float) – It is required that the float instance and a fraction instance with same value is returned. 3. class fractionsFraction(decimal): In this, it’s the necessasity the decimal instance and a fraction instance with same value is in return. 1. class fractionsFraction(string) – It is required the string or Unicode instance and a fraction instance with similar value is returned. 2. limit_denominator(max_denominator=1000000):
• It is useful for finding rational approximations to a given floating-point number.
• This is a module that finds and returns the fraction closest to self, which has denominator at most max_denominator.
• It’s also there for returning the numerator of given fraction in lowest term using the numerator property and denominator using denominator Mathematical Operations on Fractions: ###### Fraction based Calculations by Functions of Math Module: So, to see more about modules in python for data science, you can check this and this as well.

This site uses Akismet to reduce spam. Learn how your comment data is processed.