+ 1

What's the difference between a function and a method?

25th Jul 2016, 11:24 PM
Eurico Matos
Eurico Matos - avatar
4 ответов
+ 4
DEFINITELY NOT, not the same! Functions are used to do the same action for numerous objects or variables. Functions are just sets of instructions to be followed, like adding 2 numbers. Method is usually tight to a certain object type to perform a certain action over this particular object. Methods allow you to change object's property, like reversing the order of list items in the List. Functions and Methods are declared and used differently: Function: def mySampleFunction (arg1, arg2): Method: myList.reverse () if you have a list of something like myList = [1,2,3,4,5]
28th Jul 2016, 7:08 AM
Eugene E
Eugene E - avatar
+ 1
as illustrated by eugene
31st Jul 2016, 5:28 PM
sushant
sushant - avatar
- 1
both are same
27th Jul 2016, 11:38 AM
PRAVEEN KUMAR H R
PRAVEEN KUMAR H R - avatar
- 2
yes both are same
27th Jul 2016, 4:33 PM
Jeevan Chaitanya
Jeevan Chaitanya - avatar