[Tutor] float object not callable error
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Thu Oct 12 20:46:24 CEST 2006
> Here is the problem:
>
> I get 'float' object not callable error.
Hi Kristinn,
Ah. Ok. The problem is a notational one. You're reusing notation that
you've learned from your math classes, that is, that:
a b
informally represents the multiplication of numbers 'a' and 'b'.
Furthermore, math notation allows the use of parens, so:
(a) (b)
a (b)
(a) b
all designate expressions that multiply two variables together in math.
However, Python does NOT support this particular math notation! The
reason is because it conflicts with the notation used for applying
functions to arguments:
f(x)
Computers are "stupid" and computer programming languages avoid using
notations that can be ambiguously interpreted. Math notation is pretty
ambiguous sometimes, but that's usually not a problem because it's
primarily used to communicate between humans who can tease out the meaning
of the ambiguities. But, again, computers are stupid, so the notation we
use in programming is often a bit more fixed and inflexible.
In that context, take a look at the way you're notating multiplication.
Good luck!
More information about the Tutor
mailing list