In addition to the concepts from Quiz 1
and Quiz 2,
You should be able to define the following terms:
- object oriented programming
- class
- instance of a class
- data and methods of an object
- graphical user interface or GUI
- pixel
- animation
- formal parameter
- actual parameter (also known as an argument)
- function definition
- function call
- call stack
- scope of a variable
You should understand how to make instances of the following graphics
library classes and how to use their methods:
- GraphWin: getMouse()
- Point: getX(), getY()
- Line: getP1(), getP2()
- Circle: getCenter(), getRadius()
- Rectangle: getP1(), getP2()
- Graphical objects can also: draw(window), undraw(), and move(dx, dy)
Practice problems:
- Write a main program that draws a circle centered in the
graphics window with a radius of 100 and draws a line vertically from
the top of the graphics window to the bottom. The program should wait
for a mouse click to end.
- Multiple choice problems 1-5, pg. 192
- Discussion problems 1-5, pg. 193
- Write a function called avgList that takes a list of
numbers as input and returns their average. For example,
avgList([5, 10, 5, 4]) should return 6. Write a
main program to test the function.
- Write a function called maxList that takes a list of
numbers as input and returns the largest number in the list. For
example, maxList([7,4,8,1]) should return 8. Write
a main program to test the function.
- Consider the following program.
def main():
print "in main"
test = "whee"
check = "e"
answer = helper(test, check)
print "the answer is", answer
def helper(word, letter):
print "in helper"
print "word:", word
print "letter:", letter
x = 0
for ch in word:
if ch == letter:
x = x+1
# draw stack here
return x
main()
- Draw the call stack as it would look just prior to returning from
helper.
- What is the program's output (i.e. what is printed when the program is run)?
- What does the helper funciton compute?
- What would helper("moobaalalala", "a") return?
- What would helper("zoo", "a") return?
- What would be the TYPE of each of these?
p = Point(100,200) type of p?
c = Circle(p, 5) type of c?
x = c.getRadius() type of x?
c2 = Circle(p, 20) type of c2?
L = [c, c2] type of L?
m = L[0] type of m?
y = L[1].getCenter().getY() type of y?
answer = helper(test, check) type of test? type of answer (from above code)?
include("../style/footer.php"); ?>