This exam consists of three separate problems. Please write a Python program for each of the three problems and send me those three files as an attachment to an email message.

Problem One

The dot product of two vectors and is xi yi. For example, the dot product of the vectors

x = [-2,2,3]
y = [4,3,-4]

is (-2)*4 + 2*3 + 3*(-4) = -14. Write a program that computes and prints the dot product of the vectors

A = [-3, -1, 9, 7, 9, 10, -6, 4, -10, -7, 4, -8, -10, 5, -10, 0, 4, 10, -7, 5]
B = [6, 4, 2, -4, -8, -4, -5, -8, -8, -6, -5, 9, -3, -10, 10, -8, -7, 7, 5, 3]

Problem Two

Write the code for a function filter_range(X,a,b) that takes a list of numbers X as its first parameter and returns a list containing all of the numbers in X that are greater than or equal to a and less than or equal to b.

For example, if A is the list shown in question one, filter_range(A,0,6) should return the list [4, 4, 5, 0, 4, 5].

Problem Three

A text file rainfall.txt contains rainfall readings for a set of ten weather stations. On any day when one of the stations records rainfall it will send in that day's rainfall data. This results in what looks like a random list of readings from various stations over the course of several weeks.

Each line in the text file takes the form

<station number> <rainfall amount>

Write a program that reads the rainfall data from the text file and computes the total rainfall for each of the ten stations and prints a table of the totals. For example, if your program reads this input file it should print a table that looks like this:

Station Total
      1  7.66
      2  6.01
      3  9.55
      4  6.77
      5  5.63
      6  8.98
      7 11.11
      8 10.56
      9  4.96
     10  7.61