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 11 2040
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
"frankie_85" <st******@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
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
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 wrote:
a_1 = math.sqrt(math.fabs(a)) + 5((math.pow(a,3)))
TypeError: 'int' object is not callable
hint: in most programming languages, you have to use an explicit
operator to spell out multiplication. Python's no exception.
</F>
"frankie_85" <st******@gmail.comwrites:
I just made a simple code which is part of my assignment
You may want to review the restrictions your educational institution
has on collusion.
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())
This reads five values, but assigns five separate names to them. You
will want to review your course notes on Python to find out what a
'list' is.
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
The error message is telling you that you have "called" an integer
('int') object. Integer objects don't support being called like
functions.
The syntax for "calling" an object is:
foo(something, something_else)
Look at the line of code reported in the error, and you'll find an
integer object being called in that fashion. You'll need to rewrite it
so it does what you're actually trying to do.
Again, please make sure you work on these problems yourself; your
assessment should not be testing your ability to ask on the internet
for assistance.
--
\ "All good things are cheap; all bad are very dear." -- Henry |
`\ David Thoreau |
_o__) |
Ben Finney
On Sat, 28 Oct 2006 18:56:33 +1000, Ben Finney wrote:
"frankie_85" <st******@gmail.comwrites:
>I just made a simple code which is part of my assignment
You may want to review the restrictions your educational institution
has on collusion.
[snip]
Again, please make sure you work on these problems yourself; your
assessment should not be testing your ability to ask on the internet
for assistance.
I don't think the restrictions against collusion are meant to prohibit
simple "what does this error message mean?" type questions. It would be
a funny sort of learning process that forced students to live in a
vacuum, never discussing their topic with anyone else, never asking the
most trivial questions.
--
Steven.
Steven D'Aprano wrote:
On Sat, 28 Oct 2006 18:56:33 +1000, Ben Finney wrote:
>"frankie_85" <st******@gmail.comwrites:
>>I just made a simple code which is part of my assignment
You may want to review the restrictions your educational institution has on collusion.
[snip]
>Again, please make sure you work on these problems yourself; your assessment should not be testing your ability to ask on the internet for assistance.
I don't think the restrictions against collusion are meant to prohibit
simple "what does this error message mean?" type questions. It would be
a funny sort of learning process that forced students to live in a
vacuum, never discussing their topic with anyone else, never asking the
most trivial questions.
I think you are wrong. The new trend is toward absolutely no instruction
at all and the students must guess the assignment. In this regard, I
believe the OP is doing very well. Don't you think?
James
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).
You also may want to review what (the) return (keyword) really means.
Hopefully this will point you to the other problem in your code. ;-)
Steven D'Aprano wrote:
I don't think the restrictions against collusion are meant to prohibit
simple "what does this error message mean?" type questions. It would be
a funny sort of learning process that forced students to live in a
vacuum, never discussing their topic with anyone else, never asking the
most trivial questions.
the python-tutor policy is quite reasonable: http://effbot.org/pyfaq/tutor-what-i...n-homework.htm
</F>
Thanks for some of the helps guys.
Hmmm....after more trials and errors, I think what I did wrong is along
on these lines:
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)))
but I still don't understand though why the variable a, b, c, d, e
becomes an int type even though I have already specified the user input
to be floating point?
Once again thanks for all your help
"frankie_85" <st******@gmail.comwrites:
e_5 = math.sqrt(math.fabs(e)) + 5((math.pow(e,3)))
but I still don't understand though why the variable a, b, c, d, e
becomes an int type even though I have already specified the user input
to be floating point?
if you want to multiply two numbers you need to put a * between them.
* is the multiplication symbol in Python and most other languages.
When you say f(x) that says "there is a function x and Python should
call it on the value x". When you say 5(x), that says "there is
a function 5 and Python should call it with the value x". And then
when you try to actually do that, Python says "hey I can't do that,
5 isn't a function, it's an integer".
frankie_85 wrote:
Hmmm....after more trials and errors, I think what I did wrong is along
on these lines:
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)))
but I still don't understand though why the variable a, b, c, d, e
becomes an int type even though I have already specified the user input
to be floating point?
hint: besides the variables, what other values are involved in your
calculations? do you see any integers among them?
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Graeme Matthew |
last post by:
Hi all, I just wanted to tell someone :-)
I was previously a perl programmer and have been a visual basic frustrated
developer for a number of years, only for the reason that corporates are so...
|
by: Max Ischenko |
last post by:
Hi, all.
I think many would agree that the community-agreed standards could boost
the development of the applications in a defined areas. In
particular, the lack of J2EE-like standards about...
|
by: abisofile |
last post by:
hi
I'm new to programming.I've try a little BASIC so I want ask since
Python is also interpreted lang if it's similar to BASIC.
|
by: Eric S. Johansson |
last post by:
I'm creating a dialogue style interface for an application on a
dedicated system. All I have is basic Python 2.3. Is there anything
like an all Python dialog equivalent floating around? I'm...
|
by: bruce |
last post by:
hi...
i have the following test python script.... i'm trying to figure out a
couple of things...
1st.. how can i write the output of the "label" to an array, and then how i
can select a given...
|
by: mistral |
last post by:
Need compile python code, source is in html and starts with parameters:
#!/bin/sh -
"exec" "python" "-O" "$0" "$@"
I have installed ActivePython for windows.
|
by: alain MONTMORY |
last post by:
Hello everybody,
I am a newbie to python so I hope I am at the right place to expose my
problem..... :-http://www.python.org/doc/2.4.2/ext/pure-embedding.html 5.3 Pure Embedding
I download the...
|
by: nateastle |
last post by:
I have a simple assignment for school but am unsure where to go. The
assignment is to read in a text file, split out the words and say which
line each word appears in alphabetical order. I have the...
|
by: 7stud |
last post by:
My question pertains to this example:
#!/usr/bin/env python
import socket, sys, time
host = sys.argv
textport = sys.argv
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |