Homework Assignment
CS 121 (CS1)
- Homework 4 Due Wednesday, February 19, 2014
-
-
Text questions on functions
-
Exercises 2,9,10,11 at the end of Functions.
-
Functions and specs
double --
[H] Double problem. Problem 1 at this link.
Notes:-
To submit this problem, write your answer on a piece of paper or create an electronic document, and submit either on paper or attached to an email.
-
See the CS1 glossary for definitions of terms that are not listed in the text. For some examples, consider the following code:
def mean(num1, num2): x = 2 return (num1 + num2)/x mean(3, 8)
-
mean(3, 8)
is a function call -
num1
andnum2
are formal arguments -
3 and 8 are actual arguments
-
x
is a local variable. That variable is only defined within the definition ofmean()
.
-
-
Additional questions Postponed -
Trees
descendants --
Descendant trees. A tree diagram could also be used to indicate descendants of a person instead of ancestors. In this case, the root of a tree represents a person who has had children, and the nodes represent that person's children, grandchildren, etc.For example, here is a descendant tree for Queen Elizabeth II of England.
Note that a descendant tree shows all siblings, but shows only one parent of a person appearing in a descendant tree.Describing relationships between nodes. Nodes of a tree are often described in terms of their relationships to the root. For example, the nodes that connect directly to the root are often called child nodes of that root; we also speak of child nodes of another node N in the tree besides the root, meaning any nodes that are directly connected to
N
and are one level further from the root (for example, the child nodes for Anne would be Peter and Zara in the descendant tree above). This terminology is obviously inspired by descendant trees. (The same "parent-child" terminology would be used for an ancestor tree, e.g., Diana would qualify as a "child node" of William in the ancestor tree of the previous problem, even though the human relationship goes the other way around.)DO THIS: Draw a descendant tree for a real or fictional person of your choice.
-
Reading
--
Read online text: Functions if you haven't already.
submit at least one reading question by 9am before the next class meeting.--
Read online text: Selection.
submit at least one reading question by 9am before the next class meeting.
-