usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< Previous Next >>

Code for Dividing Fractions in Python



Method of Dividing Fractions

Division is the inverse operation of multiplication; That is exactly what we'll do with for fractions.
Invert the fractions that come after a division sign, as well change the division sign to multiplication, and then follow through with multiplication.


Algorithm Steps to Divide Fractions in Python

Say we are to simplify
                  21/8 ÷ 7/2;

Inverting this will yield
                  21/8 ÷ 7/2;

Then we can go ahead and multiply.


Create a new module file; Call it DivideFraction.pm.
Type out the adjoining Python code for dividing fractions.


Note: You can comment out the MultiplyFraction Python object code in the main class from the previous lesson or simply continue from where it stopped.


So!

Feel free to try out your own set of numerators and denominators for fractional division.









<< Previous Next >>