Functions in Python Language

by E-Computer Concepts October 7, 2019 at 6:54 pm

We use functions in almost every programming language. In the same way use functions in python language also so as to make together a set of instructions that one wants to use in repeated fashion or more frequently. Just because of complexity of functions, these are better to be self or auto contained in any sub program and can be simply called when needed. This means that a function in a language while programming is a piece of code which is written to carry out a specified task. To carry out that one specific or any particular type of task, the function may or may not need different or multiple inputs. When any task needs to carry out, then function may or may not return one value or more values.

Basically there are three types of functions in Python language:

Built-in functions: These are those functions which are existing already in Python. Some examples are help() to get any type of help while programming, min() which is used to get the minimum value out of set of values, print() is used to print an object.

User-Defined Functions

These functions are those which are created by users. To make their program run quicker and give results. These are declared by passing arguments to them.

Anonymous functions

These functions also known as lambda functions which means these functions are without a name because they are not declared with the standard definition keyword. The ‘def’ is a keyword which is used to declare the functions. Arguments are optional that can be set in the function declaration, by assigning them any default values. There are named arguments also, so in case of those arguments, the argument name is assigned a particular value. Functions can return a tuple, or one can return several values also using tuple unpacking. Parameters are generally passed through reference, but tuples, and ints, and strings and all immutable data types are unchangeable because only the memory location of particular item is passed.

Add Comment