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

Class Vector

This a non-graded (actually 1 point as a symbolic reward) homework (50_vclass) which mainly 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
        input:
        x - list or tuple of lenght
        sets:
        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
        https://en.wikipedia.org/wiki/Scaling_(geometry)
 
        >>> 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.txt · Last modified: 2018/08/13 09:48 (external edit)