How to Use callable() Function in PythonPython Basics


The callable() method returns True if the object appears callable, otherwise, it returns False.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print(callable(10))

def add(a, b):
    return a + b
y=add(3,4)
print(y)
print(callable(add))
print(callable(y))

Output:

False
7
True
False

Syntax

callable(object)

Parameters

object — a single argument object.

Return Value

It returns True or False.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us