Search code examples
pythonpython-3.xmathdivision

How To Find Division Without Using Division Operator In Python?


I've Found How to do it for normal numbers which gives quotient above 1

How to find value for which we will get quotient below 1

For example if 28 divided by 500 it gives 0.056

How to implement above example without using division operator


Solution

  • There is not a way to do this, unless you count reciprocals. However, these are fractions which means they use divide.

    For example:

    >>> 30 / 5 # original calculation
    6
    >>> 30 * 0.2 # using the reciprocal of 5 – but no division sign visible!
    6
    

    However, this option clearly uses division. If you don't see it, here's how:

    def divide(x, y):
        return x * (1/y)
    

    Because to make a number a reciprocal, you have to divide. But take into consideration that every whole number uses divide: 5 = 5/1, so it's just the same with a different denominator...