This Programming Assignment is similar to P6.35 in your text and you must refer to that problem for the general idea of what this problem does. The Python representation of the matrix must be a list of lists. It differs from P6.35 in the following ways:
· It is not restricted to 10x10 matrices. It should work for any size from 5x5 and larger.
· The matrix will be read from a file (see chapter 7) named terrain.txt. This file will have a row of integers representing elevations on each line. The integers will be separated by spaces. For ease of formatting the output you can assume that all elevations are less than 1000.
· A second file named flood.txt will contain one integer per line. These represent flood levels and your program should produce a map (same size as read from terrain.txt) to show the flooded terrain for each integer in the file.
· Your solution must include at least the following functions:
o readTerrain() – open and read terrain.txt, close the file, return the matrix (a list of lists) o printTerrain(elevMatrix) – print a map of terrain elevations (from readTerrain() )
o calcFlood(elevMatrix, h2oElevation) – return a matrix of strings (each position a "*" or a " " for
“flooded” and “not flooded” respectively) Any location whose elevation is less than or equal to the
h2oElevation is considered flooded.
o printFlood(floodMatrix) – cleanly print the matrix as returned by calcFlood
· Sometimes input presented to a program contains bad data. Any elevation value that is not an integer should be printed as “-“ with printing the flood map. This program will be easy to implement if you leave the data as strings in elevMatrix and use try-except (see chapter 8) when converting to integers for comparing to the flood level.
· Do NOT use list comprehensions or the .format string method.
A sample output is shown below. Build your own files to test your code.