[noob] Questions about mathematical signs...
administrata
administrata at hotmail.com
Thu Feb 10 11:44:24 EST 2005
Steve Holden <steve at holdenweb.com> wrote in message news:<v0wNd.104851$Jk5.6276 at lakeread01>...
> 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 mean you have to write a*a*a*a when you want the fourth power? You
> need the exponentiation operator ** :
>
> >>> for i in range(6):
> ... print 2 ** i
> ...
> 1
> 2
> 4
> 8
> 16
> 32
>
> > 2. Inputing fractions like (a / b) + (c / d), It's tiring work too.
> > Can it be simplified?
> >
> Surely you jest. Can you suggest a simplification, or have you come
> across one in some other language?
>
> > 3. How can i input root?
> >
> Fractional exponents give you roots (sorry about the tiring division):
>
> >>> for i in range(1,7):
> ... print i, 64 ** (1.0/i)
> ...
> 1 64.0
> 2 8.0
> 3 4.0
> 4 2.82842712475
> 5 2.29739670999
> 6 2.0
>
> > thx 4 reading :)
>
> regards
> Steve
Helpful! :)
More information about the Python-list
mailing list