| CS 331 Spring 2009 > Assignment 4 |
Assignment 4 is due at 5 p.m. Thursday, April 16. It is worth 25 points.
E-mail answers to the exercises below to ffggc@uaf.edu, using the subject “PA4”.
In this exercise, you will write some simple Python functions and classes.
Write code meeting the requirements outlined below. Place all of this in the file pa4.py. I prefer that you use Python 3. However, if this is not available to you, some recent version of Python 2 is acceptable (2.5 or 2.6). If you use a version of Python before 3.0, you must let me know this in your e-mail.
Class vec3 does not need to do any type checking.
Example code:
a = vec3(1,2,3)
b = vec3(4,5,6)
print(a) # Prints "[1, 2, 3]"
print(a+b) # Prints "[5, 7, 9]"
print(dot(a,b)) # Prints "32"
c = vec3("x", "y", "z") # Legal, as long as we don't try to add, etc.
I have written a test program: pa4_test.py (Python 3 version) or pa4_test_py2.py (Python 2 version). If you run the test program with your package, then it will test whether your package works properly.
To do the testing, place the test program and your file (pa4.py) in the same directory, and run the test program (e.g., at a Unix prompt, type “python3 pa4_test.py” or “python pa4_test_py2.py”).
Do not turn in the test program.
| CS 331 Spring 2009: Assignment 4 / Updated: 15 Apr 2009 / Glenn G. Chappell / ffggc@uaf.edu |
|