Here are the code for the first 4 sub parts
================================================================================
class Vector(): def __init__(self, dim, f): self.n = dim self.f = {} for key, val in f.items(): if val is not 0: self.f[key] = val def __add__(self, other): for i in range(self.n): if self.f.get(i) == None and other.f.get(i) == None: continue elif self.f.get(i) is not None and other.f.get(i) == None: continue elif self.f.get(i) == None and other.f.get(i) is not None: self.f[i] = other.f.get(i) else: self.f[i] = self.f.get(i) + other.f.get(i) def __neg__(self): for key, val in self.f.items(): self.f[key] = -val def __sub__(self, other): for i in range(self.n): if self.f.get(i) == None and other.f.get(i) == None: continue elif self.f.get(i) is not None and other.f.get(i) == None: continue elif self.f.get(i) == None and other.f.get(i) is not None: self.f[i] = -other.f.get(i) else: self.f[i] = self.f.get(i) - other.f.get(i) def __mul__(self, other): for i in range(self.n): if self.f.get(i) == None and other.f.get(i) == None: continue elif self.f.get(i) is not None and other.f.get(i) == None: self.f[i] = 0 elif self.f.get(i) == None and other.f.get(i) is not None: self.f[i] = 0 else: self.f[i] = self.f.get(i) * other.f.get(i) def __rmul__(self, other): for k, v in self.f.items(): self.f[k] = v * other def __truediv__(self, other): for k, v in self.f.items(): self.f[k] = v / other def norm(self): sum_square=sum(k*k for k in self.f.keys()) return sum_square**(1.0/self.n) f = {0: 1.0, 1: 0, 2: 0, 3: -1.0} v = Vector(4, f) print(v.f)
=================================================================================
T Programming for Math and Science Lab 4 March 25 and 28, 2019. Instructions: Write a module vect...
Python REALLY NEED HELP !!!!!!!!! [10pts] Write the class Vector that supports the basic vector operations. Such operations are addition (+) and subtraction (-) of vectors of the same length, dot product (*) and multiplication (*) of a vector by a scalar. All methods must return (not print) the result. Your class should also support the rich comparison for equality (==) - You must use the special methods for those 4 operators in order to override their behavior - You...