Unit 9 Flashcards
Functions
9.2 - User-Defined Function Basics
What is a function?
a grouping of pre-defined statements used for repeated operations
9.2 - User-Defined Function Basics
What is a function definition?
creates/DEFINES a new function using def
ex. def calc_area()
9.2 - User-Defined Function Basics
What is a function call?
using the function in code
ex. `print(calc_area(x, y))
9.2 - User-Defined Function Basics
What is a return statement?
a single value that a function can return
functions only return ONE thing–including containers
9.2 - User-Defined Function Basics
What is the difference between a parameter and an argument?
both serve as inputs for functions
parameter - anything
argument - number
9.2 - User-Defined Function Basics
What is a nested function?
a function that calls another function
9.2 - User-Defined Function Basics
What is a main function?
the primary section of code that eventually uses the other functions
AKA if \_\_name\_\_ == '\_\_main\_\_':
9.3 - Print Functions
What is a void function?
a function with no return value; often seen with functions that only print things
9.4 - Dynamic Typing
What is polymorphism?
adding together different types in a function
9.4 - Dynamic Typing
What is the difference between dynamic and static typing?
dynamic - determines the type of objects as a program (Python)
static - programmer must define the type for every variable & function parameter in source code (C, C++)
9.5 - Reasons for Defining Functions
What is modular development?
dividing a program into seperate modules, then develop and test the modules seperately
9.5 - Reasons for Defining Functions
Why do programmers use functions?
makes programs easier to read and debug
9.7 - Function Stubs
What is incrimental development?
writing small amounts of code and testing it; adding code incrimentally
9.7 - Function Stubs
What are function stubs?
function definitions with unwritten statements
uses pass
as a placeholder for functions
9.7 - Function Stubs
What does NotImplementedError
do?
indicates a function isn’t implemented yet; stops execution of program