Procedures in python
Procedures are computer program creates that let us capture common patterns of computation by:
- Grouping together sequences of statements
- Abstracting away from particular data values on which they perform.
Here is a procedure de?nition,17 and then its use:
def square(x):
return x * x
>>> square(6)
36
>>> square(2 - square(2))
4
We will work through, in detail, what happens when the interpreter computes a procedure de?nition, and then the application of that method.