This page is located in archive.

This is an old revision of the document!

Class Vector

This a non-graded homework which serves as a preparation for the 3rd mid-term programming test.

Create vectorclass.py module implementing a Vector class with the following methods:

class Vector:
    def __init__(self,x):
        constructor of the Vector class
        x - list or tuple of lenght
        self.x - tuple: the vector values
        self.n - vector length
        >>> v = Vector([1,2,3])
    def scaled_copy(self,scale):
        Isotropic scaling, scalar multiplication, in fact
        >>> v = Vector([1,2,3])
        >>> v2 = v.scaled_copy(3)
        >>> v.x
        [1, 2, 3]
        >>> v2.x
        [3, 6, 9]
    def __add__(self,other):
        overloading the + operator
        :return: Vector object result of the addition, None if not possible (not compatible vectors)

courses/be5b33prg/homeworks/vectorclass.1483867700.txt.gz ยท Last modified: 2017/01/08 10:28 by svobodat