CMPT 120 Lecture 21: Part 3: Functions
![CMPT 120 Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2242525-class-notes-ca-sfu-cmpt-120-lecture27.jpg)
29
CMPT 120 Full Course Notes
Verified Note
29 documents
Document Summary
Modularization: grouping of related functions in modules (python files) for better organization. Makes program easier to understand, test, and maintain. Make it easier to reuse code for multiple different programs. We import the required modules in the program. Module is a file that contains python code. Contains function definition but does not contain calls to the functions. Cannot be the same as a python keyword. # the area function accepts a circle"s radius as an. # argument and returns the area of the circle. def area(radius): return math. pi * radius**2. # radius and returns the circle"s circumference. def circumference(radius): return 2 * math. pi * radius. # the rectangle module has functions that perform. # the area function accepts a rectangle"s width and. # length as arguments and returns the rectangle"s area. def area(width, length): return width * length. # the perimeter function accepts a rectangle"s width. # and length as arguments and returns the.