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

This is an old revision of the document!


vectorlib - functions for working with vectors

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). Concentrate your test suite into a main.py file. Zip vectorlib.py and main.py into one archive file and upload it, i.e. both the library and the test suite is expected. Quality and thorougness of you testing will 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.1447414743.txt.gz · Last modified: 2015/11/13 12:39 (external edit)