CMPT 120 Study Guide - Final Guide: Local Variable, Duplicate Code, Nested Function

29
CMPT 120 Full Course Notes
Verified Note
29 documents
Document Summary
Sequence of computer program instructions that perform a specific task, packaged as a unit; this unit can then be used in the program whenever the specific task should be performed. All inputs of a function but not all functions require an input. In python, arguments of a function are contained by brackets e. g. ) float(x) * note: make sure brackets are always present regardless of presence of input. To write: start with syntax: def function_name (arguments): , then write everything needed to be implemented within the function. To call: function_name(argument) * note: function will not run when defined, and we only run when called. Sets a variable to be a value returned from a function. Local: declared within subroutines or programming blocks, can only be used within subroutine they were declared in, when subroutines end memory taken up with variable is released.