DEV Community

bakshisreeja
bakshisreeja

Posted on

functions on python

In programming, a named section of a program![]![]performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

A function is a block of code that only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.

Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks.

The term function is also used synonymously with operation and command. For example, you execute the delete function to erase a word. A callable object is an object that can accept some arguments (also called parameters) and possibly return an object (often a tuple containing multiple objects).

A function is the simplest callable object in Python, but there are others, such as classes or certain class instances. In programming, a named section of a program performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks.

We use function so we don’t need to repeat ourselves. Please watch the video below and remember the content. A function can define variables within the function body, which are considered ‘local’ to the function. The locals together with the arguments comprise all the variables within the scope of the function. Any names within the function are unbound when the function returns or reaches the end of the function body. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented, and functional programming. Python is often described as a “batteries included” language due to its comprehensive standard library.

Top comments (0)