Need help (Basic python)...what did I do wrong?

mensanator at aol.com mensanator at aol.com
Sat Oct 28 10:51:37 CEST 2006


frankie_85 wrote:
> Hi everyone,
>
> I just made a simple code which is part of my assignment but I can't
> figure it out what's wrong with it. (always give me error messages)
>
> What the code basically does is:
>
> a function that takes one floating point number x as its argument and
> returns (the square root of the absolute value of x) plus (5 times x
> cubed).
>
> and read 5 floating point values from the user into a list then apply
> the function to each value in the list and print the results in reverse
> order.
>
> --------------------------------------------------------------------------------------------
> import math
>
> print "Enter 5 values:"
> a = float(raw_input())
> b = float(raw_input())
> c = float(raw_input())
> d = float(raw_input())
> e = float(raw_input())
>
> def funct(a, b, c, d, e):
>     a_1 = math.sqrt(math.fabs(a)) + 5((math.pow(a,3)))
>     b_2 = math.sqrt(math.fabs(b)) + 5((math.pow(b,3)))
>     c_3 = math.sqrt(math.fabs(c)) + 5((math.pow(c,3)))
>     d_4 = math.sqrt(math.fabs(d)) + 5((math.pow(d,3)))
>     e_5 = math.sqrt(math.fabs(e)) + 5((math.pow(e,3)))
>     return a_1
>     return b_2
>     return c_3
>     return d_4
>     return e_5
>     print e_5, d_4, c_3, b_2, a_1
>
>
>
> funct(a, b, c, d, e)
>
>
> --------------------------------------------------------------------------------------------
>
> it always gives me these error messages:
>
> Traceback (most recent call last):
>   File "/Users/x/Documents/test3.py", line 25, in <module>
>     funct(a, b, c, d, e)
>   File "/Users/x/Documents/test3.py", line 11, in funct
>     a_1 = math.sqrt(math.fabs(a)) + 5((math.pow(a,3)))
> TypeError: 'int' object is not callable
>
> What did I do wrong?

You forgot the *.

> Please help me
> 
> Thanks in advance




More information about the Python-list mailing list