MATH 300 - Homework 7

# Math 300 - Homework 7 (back to Math 300 main page)

You must create a Python file, containing one function "plot_data". It should take 1 argument, which will be file name. The function will do the following things:

1. Open the file by the name provided as an argument (assuming file is located in the same directory as the script).
2. Read all of its contents, which will be a set of numbers (X's), each contained on a separate row (example of file format).
3. If at least one non-positive number is present amongst the data read, function should return text error message and halt its execution.
4. Calculate square root and natural logarithm for each of the abovementioned X's.
5. Plot both sets of resulting values against the abovementioned set of X's. Square roots graph should be solid and green, and its datapoints should be circled. Natural log graph will be black and dashed. There should be a legend on the figure, naming first graph as "sqrt" and other one as "ln". X-axis should be shown from -1 to 15. Other details are up to you.
Amount of rows (and numbers) in the data file is unknown in advance - your function should handle arbitrary amount of rows.

This assignment is worth 50 points, and is due at 12:00 PM on Friday, 31st of July. Mail Python script file to the instructor - do not leave it on your public directory.