def myFunction(p,r,y):
# if p, r, or y is negative, return 0
m = 1
while y > 0:
# Set m to m times (1 + r)
# Decrease y by 1
# Return p times m
Once you have filled in the blanks, save your program as
hw6a.py
and test it with a
variety of inputs, such as the following. (You’ll need to figure out on your own what the
correct answers should be.)
print myFunction(1000, .04, 1)
print myFunction(100, .02, 0)
print myFunction(3000, .06, 5)
print myFunction(-1, 3, 4)
B. Writing a Function: Adding Lists
Sometimes it is useful to add two lists together element by element. For example, suppose
the list
[1,5,29,0,2,2,0]
tells how many times you accessed the class web page each
day last week. The number of times a friend accessed the site is
[1,2,3,4,5,6,7]
. So to
calculate how many times you both accessed the web site, you would add both your lists
together, element by element:
[2,7,32,4,7,8,7]
.