- Describe what a function does in your own words
Provides a calculated result to a given input. - Calculate the output of the following function
f(x) = {
x^2 if x is even
x+10 if x is odd
}
What will be the output for the following inputs?
- a) f(2)
x=2; 2 = even; 2^2=4; output=4 - b) f(7)
x=7; 7 != even; 7+10=17; output=17 - c) f(0)
x=0; 0 = even; 0^2=0; output=0
-
Write the definition of a function f that takes an input x, divides it by four and then outputs that result subtracted by 5.
f(x) = { (x/4) -5 }