This is a little different from most of our prelabs. The last two questions have nothing to do with Lab 5; they are just here to help you prepare for Friday's exam.
Work out by hand what the following function will do. If you want to check your answer by typing the function into Python, that is fine, but you need to be able to think about recursive functions without running them..
def strange(x) : if x <= 0 : return 1 else : return 5 * strange(x-1) - 2
Consider the following figure.
Let (Ax, Ay) be the coordinates of point A, (Bx, By) those of point B, and (Cx, Cy) those of point C. The points P, Q and R are the midpoints of the three edges of the big triangle.
The following two questions have nothing to do with the lab or with recursion. This will give you some practice writing code on paper, which is a skill that a lot of beginning programming students struggle with. If you want to use helper functions to solve either of these you are welcome to, but naturally you need to write the helpers as well.
3) Write a program that has an input loop in which the user enters integers. When the input is 0 the loop should halt and the program should print the sum of all of the numbers that were entered.
4) Write a function primeCount(a, b). You can assume this will be called with integer arguments a and b with a < b. The function should return the number of primes between a and b (including both endpoints). For example, if you call primeCount(10, 19) it returns 4 because there are 4 primes between 10 and 19 (they are 11, 13, 17, 19).
If you followed the Honor Code in this assignment, write the following sentence attesting to the fact at the top of your homework.
I affirm that I have adhered to the Honor Code in this assignment.