Quiz 2 Material Flashcards
creating a function
def name(parameters):
statements…
return something
evaluate
turn an expression into a value
argument
the value/expression we send to a function
parameter
name we use for the variables in the function (you see them in the header) that are assigned to the arguments
call
to use a function
function definition
the code of the function (starts with “def”)
return
exit the value we exited with
side effect
actions that a function does (beyond returning something) that affect the environment outside of the function
in a function, it is important to _____ a value instead of printing it
return
def print_a_number(num):
print num
f1 = print_a_number(7)
print f1
7
none
do values that only existed within a function still remain in the memory after the function call line was executed?
no, python removes the memory for the function and those values are gone
scope
- the area where the variable is recognized (or has meaning)
global variables
declared outside of a function
(have scope from where they are first created until the end of the program
local variables
declared inside of a function
(have scope from where they are first created until the end of the function definition, this includes parameters)
which variable will be used? -> if the variable name is on the left of an assignment operator, it doesn’t have a value yet and the global operator is not used
python treats it as a local variable