[Tutor] Value Error

eryksun eryksun at gmail.com
Thu Jun 13 10:09:03 CEST 2013


On Wed, Jun 12, 2013 at 6:31 PM, Dave Angel <davea at davea.name> wrote:
>
>>>> i = complex(0,1)

    >>> 1j
    1j

http://en.wikipedia.org/wiki/Imaginary_unit#Alternative_notations


>>>> cmath.sqrt(float((math.e **(i * math.pi)).real))

The real/imag attributes are already floats:

    >>> from math import e, pi, sin, cos

    >>> cos(pi / 3), (e ** (1j * pi / 3)).real
    (0.5000000000000001, 0.5000000000000001)

    >>> sin(pi / 3), (e ** (1j * pi / 3)).imag
    (0.8660254037844386, 0.8660254037844386)


More information about the Tutor mailing list