im doing this code and it needs the absolute value of something here is what i have so far.

the formula it gives you is x = absolute value of the square root of radius squared minus the y-intercept squared.

this is the bit of code i have so far and both r and y have been defined.

``````import math
l = abs(math.sqrt(2)(r*r)-(y*y))``````

im getting `TypeError: 'float' object is not callable` could somebody help me out?

l = abs(math.sqrt(2)(r*r)-(y*y))
Break this formula down into one calc per line and see where the error occurs, then print the variable and it's type(variable_name), and that should tell you where you went wrong. Also, it is not polite to use "i", "l",. or "o" as single letter variable names. …

## All 4 Replies

l = abs(math.sqrt(2)(r*r)-(y*y))
Break this formula down into one calc per line and see where the error occurs, then print the variable and it's type(variable_name), and that should tell you where you went wrong. Also, it is not polite to use "i", "l",. or "o" as single letter variable names. They look like numbers and can be confusing to someone trying to decipher someone else's code.

l = abs(math.sqrt(2)(r*r)-(y*y))
Break this formula down into one calc per line and see where the error occurs, then print the variable and it's type(variable_name), and that should tell you where you went wrong. Also, it is not polite to use "i", "l",. or "o" as single letter variable names. They look like numbers and can be confusing to someone trying to decipher someone else's code.

sorry wont happen again. i did what you said an the error is coming up at r squared minus y squared? giving the same error
TypeError: 'float' object is not callable

the error is coming up at r squared minus y squared

That would be two calculations, not one, so you have to break that down and see which one is causing the error message. If this doesn't give an error message
r_squared = r*r
y_squared = y*y
sqrt_2 = math.sqrt(2)
sub_total = r_squared - y_squared
etc. (insert the rest of the equation on the lines that follow)
Then why would the one-liner show an error, and why that particular message and what does the error message mean?
l = abs(math.sqrt(2)(r*r)-(y*y))

That would be two calculations, not one, so you have to break that down and see which one is causing the error message. If this doesn't give an error message
r_squared = r*r
y_squared = y*y
sqrt_2 = math.sqrt(2)
sub_total = r_squared - y_squared
etc. (insert the rest of the equation on the lines that follow)
Then why would the one-liner show an error, and why that particular message and what does the error message mean?
l = abs(math.sqrt(2)(r*r)-(y*y))

Alright that did the trick no errors came up now i just gotta print out whatever that equals?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.