Introduction to Functions in Python

At the core of programming languages is the idea of functions.

However, languages tend to treat them differently.

In most programming languages, the attitute towards a function is as a way of encapsulating code. They take some parameters, execute code and return data and that's it.

However, python as well as many modern languages do take the notion of function much more than just a code capsule. They treat functions as full objects. As objects they can be passed around, wrapped in other functions or replaced by new implementations.

In short functions are also types.

The built-in function type forms the basis of functions in Python.

Checking Function Type

In fact we can check the type of a given function using the type() function.

def greet():



<class 'function'>

Function Arguments/Parameters

Functions always can take arguments. And this is one of the secrets of their power. However, python takes this power to the next level in that it allows us pas keyword arguments and even arguments that won't be know until runtime when the function is invoked.

For example, the following simple example allows us specify an argument that will only be entered at runtime.

def greet(name):
    return 'Hello ' + name

name=input("Enter You Name to receive a Greeter: ")


Enter You Name to receive a Greeter: Oclemy
Hello Oclemy

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:


What do You Think

Previous Post Next Post