Explain why the dot operator is used in both math squareroot

Explain why the dot operator is used in both math. squareroot and L.append. One is a function from an imported module and the other is a method of the list class. Why do you suppose the developers of the Python programming language used the dot (.) in both of these contexts?

Solution

Python uses dot notation to specify a location to look for a function. Classes and Modules are two important parts of Python.

Classes are a fundamental part of Python. They are ways of defining a set of objects by having a uniform set of variables and functions(methods).

Modules are files that contain lots of useful code that is meant to be reused.

We use dot notation to use a method (which is another name for a function but for classes), on a specific object. Lists are objects. So L.append() is calling the list method append on the object L.

We also use dot notation to refer to a function that is inside a module. The module math contains function called sqrt. So to find the square root, we would write math.sqrt().

 Explain why the dot operator is used in both math. squareroot and L.append. One is a function from an imported module and the other is a method of the list cla

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site