Unit 10 Flashcards
10.2 - Functions are Objects
What is bytecode?
a low-level operation performed by the interpreter
kinda like mental math
10.3 - Scope of Variables and Functions
What is scope?
a domain where variables/functions are only visible to part of a program
10.3 - Scope of Variables and Functions
What is a local variable?
a variable located within an inner scope
ex. within functions, loops, etc.
10.3 - Scope of Variables and Functions
What are global variables?
variables within a scope that extends outside the local
10.3 - Scope of Variables and Functions
Why are global variables frowned upon?
encourages lazy programming; functions may change variables
10.4 - Namespaces & Scope Resolution
What is a namespace?
a component that maps names to objects
10.4 - Namespaces & Scope Resolution
What is scope resolution?
the process of searching for a name in the available namespace
10.5 - Keyword Arguments & Default Parameter Values
What are keyword arguments?
maps values to parameters based on name
ex. split_check(125.00, tip_percentage=0.15, num_people=2, tax_percentage=0.095)
10.5 - Keyword Arguments & Default Parameter Values
What are default parameter values?
placeholder values for function arguments
10.6 - Arbitrary Argument Lists
What is an arbitrary argument list?
a tuple that allows for additional parameters in a function
uses *args
10.6 - Arbitrary Argument Lists
What are keyword arguments?
a dictionary for extra arguments
uses **kwargs
like an AAL
10.7 - Multiple Function Outputs
What is packing and unpacking?
returning several outputs using a container; a statement performs several assignments to accomodate for the outputs
10.8 - Using Docstrings to Document Functions
What is a docstring?
using '''
or """
to denote a comment
10.8 - Using Docstrings to Document Functions
What does help()
do?
provides documentation associated with an object
10.10 - Function Arguments
What is a pass-by-assignmnent?
arguments in functions are passed by object reference
global -> object -> local