Python‎ > ‎operator‎ > ‎

operator.truediv()


Definition
The method return with the division of a/b.

Syntax
operator.truediv(a,b)

Parameters
numbers

Examples
The method returns as follow:
 >>> operator.truediv(complex(2255888+0j),22)
(102540.36363636363+0j)
>>>

__truediv__
The method return same value:
 >>> complex(2255888+0j).__truediv__(22)
(102540.36363636363+0j)


The returns is:
 >>> a= Decimal(2.31).compare_total_mag(Decimal(9.22))
>>> b=Decimal('-1')
>>> operator.truediv(a,b)
Decimal('1')

Operator.truediv(random)
The method used the math values to generate random using operator.truediv()
import operator
import random
import math

a=math.acos(.65)
b=math.asin(.45)
c=math.atan(1)

d=random.betavariate(a,b)
f=random.gauss(b,c)
g=random.gammavariate(c,a)

h=operator.truediv(d,f)
i=operator.truediv(f,g)
j=operator.truediv(g,d)

list=[h,i,j]

l=max(map(lambda x:x, list))

print(l)

>>> 
426.5194858354276
>>>

__truediv__
The equation value is determined through input().
import math
import operator
a=float(input("Please enter copysign(x) : "))
b=float(input("Please enter copysign(y) : "))

c=math.copysign(a,b).__add__(1.1).__mul__(math.acosh(2)).__truediv__(math.atan2(88,34))
print("The equation value is", c)

>>> 
Please enter copysign(x) : 2
Please enter copysign(y) : 6
The value is 3.3961966891396522
>>> 

Comments