Introduction to Python
Programming Cycle of Python
Varibles and Datatypes in Python
Input and Output in Python
Operators in Python
Precedence of Operators in Python
Typecasting in Python
If Else in Python
Loops in Python
Break, Continue and Pass in Python
Functions in Python
Default Arguments and Keyword Arguments in Python
Strings in python
Lists in Python
Tuple in Python
Dictionary in Python
Sets in Python
List Comprehension in Python
Unpacking Sequences in Python
Higher Order Functions in Python
Lambda Functions in Python
Sieve of Eratosthenes Algorithm in Python
Linear Search in Python
Binary Search in Python
Selection Sort in Python
Bubble Sort in Python
Insertion Sort in Python
Merge Sort in Python
Higher order functions in Python
In Python, functions are called first-class objects i.e. they can be passed as parameters
to other functions or one function can be returned by another function. The functions that use or
returns other functions are called Higher-order functions. Consider the following code.
def hello(name):
print("Hello,",name)
def func(func2):
print("Calling hello")
func2("rapid coders")
print("Calling func")
func1(hello)
Output
Calling func1 Calling hello Hello, rapid coders
Functions can also be assigned to variables. For example -.
def hello():
print("hello from python")
hello_python=hello
print(hello_python())
Output
hello from python
A function can also return another function.
def hello1():
print("hello from python")
def hello2():
print("hello from rapid coders!")
return hello2()
func=hello1()
print("Calling func")
func()
Output
hello from python Calling func hello from rapid coders!