×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to pass function as an argument

Here, we are going to learn how to pass function as an argument in Python? By Shivang Yadav Last updated : January 05, 2024

Python allows programmers to pass functions as arguments to another function.

Such functions that can accept other functions as argument are known as higher-order functions.

Program to pass function as an argument

# Function - foo()
def foo():
    print("I am Foo")

# higher-order function - 
# koo() accepting foo as parameter 
def koo(x):
    x()

# function call with other function 
# passed as argument
koo(foo)

Output

The output of the above program is:

I am Foo

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.