A Brief Introduction to Methods and Functions

In the following lesson, you will be given a very brief introduction on methods and functions.


In computer programming, a function or a method is a block of code that performs a specific task. That block of code is then given a name (much like a variable) that is called whenever that specific task needs to be performed. This removes the need to type the same code over and over again; all you have to do is call the function’s name.

How Do They Work?

Like mathematical functions, programming functions take in an input, known as an argument, perform some operations on that input, and then return the resulting output.

It’s almost like a conveyer belt in a factory with items entering the machine from one end of the conveyer belt and coming out, completely modified, on the other end. However, as the machine remains the same throughout its life, it will modify every item that enters it the same way.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy