Warning

This page is located in archive.
Go to the latest version of this course pages.
Go the latest version of this page.

See the general homework guidelines!

Create `vectorlib.py`

file-library that will contain the functions listed below. Your library is going to be imported, it must work as as a library (pure functions).
Optionally, include example usage of the functions within docstrings and test your module using `doctest`

. The tests will not be evaluated.

Vectors will be lists. You can define some auxiliary function in your library. Also, think about re-using functions within other functions. If you have problems with the math background ask your teachers or a book or Wikipedia or any other math resource.

Five points for the code functionality (automatic check) and two points for the code quality (readability, conciseness).

def scalar_mult(sc,v): """ scalar multiplication (scalar * vector) :param sc: a scalar mulitplier :param v: a list - vector :return: sc * v """ def dot_product(u,v): """ vector dot product :param u: a list :param v: a list :return: None if u and v are not compatible otherwise a number (float or int) """ def cross_product(u,v): """ vector cross product, see :param u: a list of lenght 3 :param v: a list of length 3 :return: None if u and v are not compatible a list of lenght 3 - cross product of u and v """ def are_colinear(u,v): """ testing colinearity of two vectors :param u: a list :param v: a list :return: True if u and v are colinear, False otherwise """ def are_perpendicular(u,v): """ testing perpendicularity of two vectors :param u: a list :param v: a list :return: True if u and v are perpendicular, False otherwise """

- 5 points for automatic checks
- 2 points for manual evaluation (is the code readable, did you use the docstring to comment your function (in this case it is pre-made for you), did you
**explain the logic of your code**in the associated comments.)

courses/be5b33prg/homework/regular/03_vector_library.txt · Last modified: 2020/11/09 13:18 by nemymila