Can anyone tell me the difference between a method and a function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone tell me the difference between a method and a function?

25th Jan 2016, 7:12 AM
Yeshvendra Kumar Singh
Yeshvendra Kumar Singh - avatar
3 Answers
+ 4
Methods are usually constructs that take arguments but return none. Functions take arguments and return values. An example for a method would be the print "function"; one for a function would be the len(list) function.
5th Feb 2016, 10:29 AM
tim
+ 1
technically, methods are function, but defined within an object. Objects may have properties which are variables within the object or methods which are functions within. you will learn more later in OOP section
16th Feb 2016, 7:07 AM
Mostafa Ahangarha
+ 1
method is the way of making a programme or can say that take arguments but do not return anything.(eg.print it is fixed ) while functions are set of operations to do a specific taskn like ('range' tells you the range of list).
19th Jul 2016, 7:45 AM
Shishir Ranjan
Shishir Ranjan - avatar