需要帮助(基本python)...我做错了什么? [英] Need help (Basic python)...what did I do wrong?

查看:58
本文介绍了需要帮助(基本python)...我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我刚刚编写了一个简单的代码,这是我的任务的一部分,但是我不能确定
弄清楚是什么''错了。 (总是给我错误信息)


代码基本上做的是:


a函数,它将一个浮点数x作为参数,

返回(x的绝对值的平方根)加上(5倍x

立方)。


并读取从用户到列表中的5个浮点值然后对该列表中的每个值应用

函数并反向打印结果

order。


-------------------------------------------- ------------------------------------------------ <无线电通信/>
导入数学


print"输入5个值:"

a = float(raw_input())

b = float(raw_input())

c = float(raw_input())

d = float(raw_input())

e = float( raw_input())

def功能(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)))

返回a_1

返回b_2

返回c_3

返回d_4

返回e_5

打印e_5,d_4,c_3,b_2,a_1


功能(a,b,c,d,e)

----- -------------------------------------------------- -------------------------------------


吧总是给我这些错误信息:


回溯(最近一次调用最后一次):

文件" /Users/x/Documents/test3.py",第25行,在< module>

功能(a,b,c,d,e)

文件" /Users/x/Documents/test3.py" ,第11行,在功能中

a_1 = math.sqrt(math.fabs(a))+ 5((math.pow(a,3)))

TypeError :''int''对象不可调用


我做错了什么?请帮帮我


提前致谢

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? Please help me

Thanks in advance

推荐答案



frankie_85写道:

frankie_85 wrote:

大家好,


我刚做了一个简单的代码,这是我的任务的一部分,但我可以'$ b / b
弄清楚它有什么问题。 (总是给我错误信息)


代码基本上做的是:


a函数,它将一个浮点数x作为参数,

返回(x的绝对值的平方根)加上(5倍x

立方)。


并读取从用户到列表中的5个浮点值然后对该列表中的每个值应用

函数并反向打印结果

order。


-------------------------------------------- ------------------------------------------------ <无线电通信/>
导入数学


print"输入5个值:"

a = float(raw_input())

b = float(raw_input())

c = float(raw_input())

d = float(raw_input())

e = float( raw_input())

def功能(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)))

返回a_1

返回b_2

返回c_3

返回d_4

返回e_5
打印e_5,d_4,c_3,b_2,a_1


功能(a,b,c,d,e)


------------------------------------------------- -------------------------------------------

它总是给我这些错误信息:


Traceback(最近一次调用最后一次):

文件" / Users / x / Documents /test3.py" ;,第25行,在< module>

funct(a,b,c,d,e)

文件" / Users / x / Documents / test3.py",第11行,函数

a_1 = math.sqrt(math.fabs(a))+ 5((math.pow(a,3)))

TypeError:''int''对象不可调用


我做错了什么?
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




" frankie_85" < st ****** @ gmail.comschreef在bericht

新闻:11 ********************** @ m73g2000cwd .googlegr oups.com ...

"frankie_85" <st******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...

大家好,


我刚做了一个简单的代码,这是我的一部分任务,但我不能确定它有什么问题。 (总是给我错误信息)


代码基本上做的是:


a函数,它将一个浮点数x作为参数,

返回(x的绝对值的平方根)加上(5倍x

立方)。


并读取从用户到列表中的5个浮点值然后对该列表中的每个值应用

函数并反向打印结果

order。


-------------------------------------------- ------------------------------------------------ <无线电通信/>
导入数学


print"输入5个值:"

a = float(raw_input())

b = float(raw_input())

c = float(raw_input())

d = float(raw_input())

e = float( raw_input())

def功能(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)))

返回a_1

返回b_2

返回c_3

返回d_4

返回e_5

打印e_5,d_4,c_3,b_2,a_1


功能(a,b,c,d,e)


-------------------------------------------------- ------------------------------------------


它总是给我这些错误信息:


回溯(最近一次调用最后一次):

文件" / Users / x / Documents / test3.py",第25行,< module>

功能(a,b,c,d,e)

文件" / Users / x / Documents /test3.py" ;,第11行,在功能中

a_1 = math.sqrt(math.fabs(a))+ 5((math.pow(a,3)))

TypeError:''int''对象不可调用


我做错了什么?请帮帮我


提前致谢
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? Please help me

Thanks in advance



显然错误在行中a_1 = math.sqrt(数学.fabs(a))+

5((math.pow(a,3)))


尝试将此变为a_1 = math.sqrt(math.fabs(a))+ 5 * math.pow(a,3)"


因为你似乎想要5次pow()的结果功能



obviously the error is in the line "a_1 = math.sqrt(math.fabs(a)) +
5((math.pow(a,3)))"

try changin this to "a_1 = math.sqrt(math.fabs(a)) + 5*math.pow(a,3)"

because you seem to want 5 time the result of the pow() function



frankie_85写道:
frankie_85 wrote:

a_1 = math.sqrt(math .fabs(a))+ 5((math.pow(a,3)))

TypeError:''int''对象不可调用
a_1 = math.sqrt(math.fabs(a)) + 5((math.pow(a,3)))
TypeError: ''int'' object is not callable



提示:在大多数编程语言中,你必须使用一个明确的

运算符来拼出乘法。 Python也不例外。


< / F>

hint: in most programming languages, you have to use an explicit
operator to spell out multiplication. Python''s no exception.

</F>


这篇关于需要帮助(基本python)...我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆