Skip to main content

How to Resolve "TypeError: 'float' object is not callable" in Pytohon

When programming in Python, you might encounter the TypeError: 'float' object is not callable. This error occurs when you use parentheses () on a variable that holds a floating-point number, treating it as if it were a function. In Python, the () syntax is the "call" operator, reserved for executing functions or methods.

The error is a clear signal that there's a syntax mistake or a variable naming conflict in your code. This guide will walk you through the three most common scenarios that cause this error and show you how to resolve each one.

Understanding the Error: The "Call" Operator ()

In Python, an object is "callable" if you can execute it using parentheses (). Functions and methods are callable. Data types like integers, floats, and strings are not callable.

The TypeError: 'float' object is not callable means Python has encountered code like my_float_variable(...) and is telling you that the variable my_float_variable contains a float, which is just data and cannot be executed as a function.

Cause 1: Missing Multiplication Operator *

This is a common syntax error, especially when translating mathematical notation directly into code. In math, x(y+z) implies multiplication, but in Python, it means "call the function x".

Example of code causing the error:

my_float = 7.2

# Incorrect: Python sees this as trying to call my_float as a function.
result = my_float(5 - 2)

Output:

Traceback (most recent call last):
File "main.py", line 4, in <module>
result = my_float(5 - 2)
TypeError: 'float' object is not callable

Solution: you must use the explicit multiplication operator (*) to perform multiplication.

my_float = 7.2

# ✅ Correct: Use the '*' operator for multiplication.
result = my_float * (5 - 2)

print(result)

Output:

21.6

Cause 2: Variable Name Shadowing a Built-in Function

This error can occur if you accidentally name a variable with the same name as a built-in Python function, such as float, sum, or min. This reassignment "shadows" or hides the original function.

Example of code causing the error:

# ❌ Incorrect: The variable 'float' now holds a float value, overwriting the built-in function.
float = 3.14

# This line now tries to "call" the float variable 3.14, not the function.
another_float = float("7.55")

Output:

Traceback (most recent call last):
File "main.py", line 5, in <module>
another_float = float("7.55")
TypeError: 'float' object is not callable

Solution: never use the names of built-in functions as variable names. Choose a descriptive name for your variable instead.

# ✅ Correct: Use a unique variable name.
my_float_variable = 3.14

# The built-in float() function is no longer shadowed and works as expected.
another_float = float("7.55")

print(another_float)

Output:

7.55

Cause 3: Variable Name Shadowing a User-Defined Function

The same shadowing problem can happen with your own functions. If you define a function and later create a variable with the exact same name, you will overwrite the function.

Example of code causing the error:

def calculate_area():
return 100.5

# ... later in the code ...

# ❌ Incorrect: The name 'calculate_area' is reassigned to a float value.
calculate_area = 50.5

# This now tries to call the float 50.5, not the function.
area = calculate_area()

Output:

Traceback (most recent call last):
File "main.py", line 10, in <module>
area = calculate_area()
TypeError: 'float' object is not callable

Solution: always use unique and descriptive names for your variables and functions to avoid conflicts.

def calculate_area():
return 100.5

# ✅ Correct: Use a different name for the variable.
calculated_value = 50.5

# The original function remains accessible.
area = calculate_area()

print(area)

Output:

100.5

Conclusion

The TypeError: 'float' object is not callable is always caused by using the call operator () on a variable that contains a float. To fix it, you need to find where this is happening in your code:

If the cause is...The solution is...
Implicit multiplication (e.g., x(y))Add the explicit multiplication operator: x * (y).
A variable name that is the same as a built-in function (e.g., float = ...)Rename your variable to something that is not a built-in name.
A variable name that is the same as one of your own functionsRename either the variable or the function to ensure all names are unique.

By carefully checking your syntax and variable names, you can easily diagnose and resolve this common TypeError.