---
title: "What's the difference between a method and a function?"  
description: "What's the difference between a method and a function?"  
author: "Utpal Vishwas"  
published: 2023-04-11  
updated: 2023-04-17  
canonical: https://www.mindstick.com/forum/157748/what-s-the-difference-between-a-method-and-a-function  
category: "python"  
tags: ["python", "python 2"]  
reading_time: 2 minutes  

---

# What's the difference between a method and a function?

What's the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between a [method](https://www.mindstick.com/forum/166/webservice-method) and a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)?

## Replies

### Reply by Aryan Kumar

A **function** is a set of instructions or procedures to perform a specific task, and a **method** is a set of instructions that are associated with an object.

A function is used to split the code into easily understandable parts, which can be reused as well.\
\
**Difference between Method and function are:** \
A function doesn’t need any object and is independent, while the method is a function, which is linked with any object.

- We can directly call the function with its name, while the method is called by the object’s name.
- Function is used to pass or return the data, while the method operates the data in a class.
- Function is an independent functionality, while the method lies under object-oriented programming.
- In functions, we don’t need to declare the class, while to use methods we need to declare the class.
- Functions can only work with the provided data, while methods can access all the data provided in the given class.

### Reply by Krishnapriya Rajeev

In programming, both methods and functions are used to *define reusable pieces of code*. The main difference between a method and a function is their context and usage.

A **function** is a self-contained block of code that takes input, processes it, and returns output. It can be called from anywhere in the program and can be reused multiple times. Functions are generally used to perform a specific task that can be done independently of any object. Therefore, we can say the data is passed explicitly.

On the other hand, a **method** is a function that is associated with an *object*. It is defined within a class and is used to manipulate the object's data. A method is called on an *instance of a class* and is used to modify its attributes or perform an action specific to that object. Therefore, we can say data is passed implicitly as it is dependent on the object.


---

Original Source: https://www.mindstick.com/forum/157748/what-s-the-difference-between-a-method-and-a-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
