Python Exam 2 Flashcards
parameter
value passed into a function by its caller
def <name>(<name>):
<statement(s)></name></name>
multiple parameters
a function can accept multiple parameters.
Separate each parameter by a comma
When calling has to have every parameter needed
value semantics
When numbers and strings are passed as parameters, their values are copied
Modifying the parameters will not affect the variable passed in
math.ceil(value)
rounds up
math.floor(value)
rounds down
math.log(value)
logarithm
requires import math
math.sqrt(value)
square root
requires import math
math.sinh(value)
math.cosh(value)
math.tanh(value)
hyperbolic sine/cosine/tangent of an angle in radians
requires import math
math.degrees(value)
math.radians(value)
convert to degrees and radians and back
requires import math
e
2.7182818
requires import math
pi
3.1515926
requires import math
abs(value)
absolute value
min(value1, value2)
smallest of 2 values
max(value1, value2)
largest of 2 values
round(value)
nearest whole number
math functions
imply calling these functions produces not visible result
Math function calls use a python feature called return values that cause them to be treated as expressions
The program runs the function, computes the answer, and then replaces the call with its computer result value
To see the result, we must print it or store it in a variable
return
to send a value as the result of a function call