6 Functions Flashcards
Docstring format
def drawsquare(t, sz): """Make turtle t and draw square of size sz"""
Runtime-retrievable documentation
Docstring
Function Call other name
Function Invocation
Function Invocation other name
Function Call
Functions that return are called
Fruitful
Default return of functions
None
“Same thing” as far as unit test parameters are concerned
Equivalence Class
Local and global variables of same name
Shadowing
Parameters vs Arguments
Arguments are actual parameters/things given
How say __main__
Dunder main
How to invoke main() selectively
if __name__ == “__main__”:
main()
Rounding
round(1.001) == 1 ==> True
Pytest format
def test_3_to_the_2(): assert 9 == math.exponent(3, 2)
Functional decomposition
Breaking big problems into smaller ones
Breaking big problems into smaller ones
Functional Decomposition
Flow of Execution
Order statements are executed
Order statements are executed
Flow of Execution
Doing and testing small bits at a time
Incremental Development
Incremental Development
Doing and testing small bits at a time
Building functions using other functions
Composition
Composition
Building functions using other functions