Composition
Get introduced to the concept of composition in Python with the help of the examples provided in this lesson.
We'll cover the following...
What is composition?
It is quite common in programming to have one function operate on the result of another function.
For example, to calculate the square of the sine of x
we use square(math.sin(x))
. To create an iterator that counts down from n
-1 to 0, we use reversed(range(n))
.
We refer ...