How To Find Division Without Using Division Operator In Python?

Question:

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

Asked By: Sunilsai

||

Answers:

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…

Answered By: monsieuralfonse64
#in this case 18/2
e=18
t=2

o=0
l=t
count=0
t=0
for i in range(0,e):
  t+=l
  count+=1
  if t==e:
    o=1
    print(count)
    break
  if (t+l) > e:
    break
if o!=1:
  c=e-t
  print(count,'reminder of',c)
Answered By: greatseal
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.