i need help on builtin function math 
Author Message
 i need help on builtin function math


Quote:
> hello !

> i want to use the sqrt() function of the builtin funtion math in that
> kind:

> import math
> ...
> a=0
> a=sqrt(whatever)

> and than a NameError: sqrt occured and i dont know why ? Is it
> depending on the OS (i use Windows98 and the pywin
> editor). Other functions, like pow(), from the math module are working.
> Can anyone help me with my problem ?

if you 'import math' then you have to call it as math.sqrt().


Mon, 15 Sep 2003 07:39:37 GMT  
 i need help on builtin function math
hello !

i want to use the sqrt() function of the builtin funtion math in that
kind:

import math
...
a=0
a=sqrt(whatever)

and than a NameError: sqrt occured and i dont know why ? Is it
depending on the OS (i use Windows98 and the pywin
editor). Other functions, like pow(), from the math module are working.
Can anyone help me with my problem ?

thanks a lot
greetings
Marcus



Mon, 15 Sep 2003 07:32:02 GMT  
 i need help on builtin function math
Marcus Konermann schrieb in Nachricht ...

Quote:
>i want to use the sqrt() function of the builtin funtion math in that
>kind:

>import math
>...
>a=0
>a=sqrt(whatever)

Try this:
Quote:
>>> import math
>>> a = 0
>>> a = sqrt(34)

Traceback (innermost last):
  File "<interactive input>", line 1, in ?
NameError: There is no variable named 'sqrt'
Quote:
>>> a = math.sqrt(34)
>>> a

5.8309518948453007

or this:

Quote:
>>> from math import *
>>> a = sqrt(34)
>>> a

5.8309518948453007

HTH,
Rdiger



Mon, 15 Sep 2003 17:23:19 GMT  
 i need help on builtin function math

Quote:
> hello !

> i want to use the sqrt() function of the builtin funtion math in that
> kind:

> import math
> ...
> a=0
> a=sqrt(whatever)

> and than a NameError: sqrt occured and i dont know why ? Is it
> depending on the OS (i use Windows98 and the pywin
> editor). Other functions, like pow(), from the math module are working.

There is a *built-in* function pow, which is not the same
as math.pow, and is no doubt what IS being executed here:

Quote:
>>> pow

<built-in function pow>
Quote:
>>> import math
>>> math.pow

<built-in function pow>
Quote:
>>> pow is math.pow
0
>>> math.pow(2, 35000)

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: math range error
Quote:
>>> pow(2, 35000)

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: integer exponentiation

Quote:

> Can anyone help me with my problem ?

Either:
    import math
    a=math.sqrt(whatever)
or:
    from math import sqrt
    a=sqrt(whatever)

Alex



Mon, 15 Sep 2003 16:56:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Builtin methods versus Builtin Functions -- help!

2. Pickler that handles modules, functions, and builtin functions -- done

3. generic functions to redefine builtin functions - how ?

4. built-in math functions (was Re: RXMATH math package for REXX)

5. Additions to math.c (more math functions)

6. Uncommon Math Functions on a Math-Coprocessor

7. Uncommon Math Functions on a Math-Coprocessor

8. Math Functions for Windows needed!

9. math functions help

10. math: passing function to function

11. TIP #15: Functions to List and Detail Math Functions

12. Help Anyone ammer/Analyst needs Math

 

 
Powered by phpBB® Forum Software