|
First Summer 2006
|
Lab Twelve: Methods
Consider this:
def f(x):
return g(x) + (h(h(x))
def g(x):
return 4 * h(x)
def h(x):
return x * x + k(x) - 1
def k(x):
return 2 * (x + 1)
Given the definitions above:
- What does evaluate to?
- What does evaluate to?
- What does evaluate to?
- What does evaluate to?
- What does
f(-1) + g(-1) + h(-1) + k(-1)
evaluate to?
Justify your answers.
The lab assignment for today is this:
- Write a method that calculates the sum of all elements in a list of numbers.
- Write a method that counts the number of even numbers in a list of numbers.
- Write a method that takes two arguments:
- a list of numbers (integers) call it
data and
- an integer
a
and returns a list with all occurences of a removed.
- Write a method that sorts a list of numbers in ascending order.
- Write a method that takes a list of numbers and removes from all elements that appear for a second time (or more) in the list.
Do as much as you can, turn in what you have at the end of the lab.
Last updated: May 30, 2006 by Adrian German for A201/A597