-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

    it's Ok. Python gets from 1/2 0 as 0 is the integer part of that
division. So, Python is interpreting -1**0 so you get 1 as answer.

you should try this (-1)**(1.0/2.0) so 1.0/2.0 is an operation returning
 0.5 completely.

 and you'll get:

>>> (-1)**(1.0/2.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: negative number cannot be raised to a fractional power


Regards,

 Jesús (Neurogeek)


Jonathan Barbero wrote:
> Hello!
>   My name is Jonathan, i´m new with Python.
> 
>    I try this in the command line:
> 
>    >>> (-1)**(1/2)
>     1
> 
>    This is wrong, i think it must throw an exception.
>     What do you think?
> 
>     Bye.
>         Jonathan.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/jrivero%40python.org.ve

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD+eA4dIssYB9vBoMRAuZXAJ4/hc6FrApyDxFScsv8w1kjc+Yi8QCfWzdb
Izl2OQUE3iPVeqBnvjErrHA=
=y5uC
-----END PGP SIGNATURE-----
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to