0

What would you call this?

I am seeing terms such as: math.sqrt or math.fabs what is math? Is this a function? What is the difference between a function and a method in English please

11th Jan 2017, 2:01 AM
Andrew Rivera
Andrew Rivera - avatar
3 Antworten
+ 6
A function basically does something. Like math.ceil() A method basically calls something else. You need to have what the method does somewhere else.
11th Jan 2017, 2:15 AM
J.G.
J.G. - avatar
+ 2
I think math is a class that calls on mathematical functions. So for example math.sqrt( 64 ) would take the square root of 64. math.fabs( x ) returns the absolute value of x. A function, in the way I think of it, is a way to complete specific actions, for example print. I'm not really sure of everything for python since all I know, for now, is Java, and I'm still fairly new to all this myself. I recommend going to docs.python.org and going through the documentation to help answer your questions.
11th Jan 2017, 2:48 AM
Phoenix28
Phoenix28 - avatar
0
In *English*, they are both the same. It's something about method being the 'preferred' word of choice in Object Oriented Programming, but that's all boring for the English init? Math.sqrt returns the square root of a term. Math.fabs returns the absolute value of a term. In *Mathematics*, 'Finding the square root of a term' is a "Logarithmic Function" and 'Finding the absolute value' is a "Number-Theoretic Function". In *Programming*, .sqrt and .fabs are both methods of the math class.
11th Jan 2017, 2:29 AM
Imran Din
Imran Din - avatar