What are functions in Python?

A function is a block of code which is executed only when it is called. To define a Python function, the def keyword is used. You can pass data, known as parameters, into a function. A function can return data as a result.


def my_function(name):
    print("Hi, Welcome to",name)

# Calling the function

Output: Hi, Welcome to ProgramsBuzz.