[noob] Questions about mathematical signs...

Jeff Epler jepler at unpythonic.net
Sun Feb 6 15:43:07 EST 2005


On Sun, Feb 06, 2005 at 12:26:30PM -0800, administrata wrote:
> Hi! I'm programming maths programs.
> And I got some questions about mathematical signs.
> 
> 1. Inputing suqare like a * a, It's too long when I do time-consuming
>    things. Can it be simplified?

You can write powers with the "**" operator.  In this case,
    a ** 2

> 2. Inputing fractions like (a / b) + (c / d), It's tiring work too.
>    Can it be simplified?

Because of the rules of operator precedence,
    a / b + c / d
has the same meaning as the expression you gave.

> 3. How can i input root?

Assuming that you've already executed
    import math
Here are some ways to find the square root of a number:
    math.sqrt(4)
    4 ** .5
    math.pow(4, .5)

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050206/be7c951c/attachment.sig>


More information about the Python-list mailing list