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

vectorlib - functions for working with vectors

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 backround 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
    """

courses/be5b33prg/homeworks/vectorlib.txt · Last modified: 2017/11/15 15:02 by petrito1