Question: In lab you created the T88ble, now you will create arr88, which are similar to numpy arrays from Data 8. Complete thelen and item functions

In lab you created the T88ble, now you will create arr88, which are similar to numpy arrays from Data 8. Complete thelen and item functions according to the docstrings. len is a special attribute, like_init that allows us to call len on our Arr88s to get their length! def en (self): add and muare also special attributes, likeinit and enthat allow us to use + and on our Arr88s to add/mult ply them componentw se! Question 1 Get the length of the Arr88 arr88 Arr88([1, 2, 3]) >len(arr88) 2defadd_ (self, arr88): Add two ArrB8s of the same length componentwise arr88Arr88([1, 2, 3, 41) len(arr88) arr88aArr88([1, 2, 31) arr88bArr88( [4, 5, 61) arr88aarr88b Arr88( [5, 7, 91) >>> arr88a # We aren't mutating arr88a Arr88([1, 2, 31) YOUR CODE HERE return def item(self, i): arr88aarr88b Arr88(['Hello', 'World,'') Get the item of the Arr88 at index i arr88ArrB8( [1, 2, 31) arr88.item(1) # Checks that the lengths are the same assert len(self) :-len (arr88) YOUR CODE HERE arr8B. item(0) return def-mul-(self, arr88): YOUR CODE HERE return Multiply two Arr88s of the same length componentwise arr88aArr88(11, 2, 31) arr88bArr88([4, 5, 6]) arr88a arr88b Arr88(14, 10, 18]) >>> arr88a # We aren't mutating arr88a Arr88([1, 2, 31) arr88bArr88( [18, 1, 51) arr88aarr88b Arr88(['NaNaNaNaNaNaNaNaNaNa",'Batman''!!!' # Checks that the lengths are the same assert len(self len(arr8B YOUR CODE HERE return Complete the apply function that returns a new Iist with the function applied to every element. def negate(self: def apply(self, func): Negate an Arr8B with mutation arr88aArrBB([1, 2, 3]) 3Apply a function to an Arr88 >>> arr88b = Arr88( [4.0,-5.5, 8.0)) >>> arr88a=Arr88([1, 2, 31) arr88a.negate() arr88a arr88a.apply(lambda x x *x) Arr88[1, 4, 91) >>> arr88a # We aren't mutating arr88a Arr88( [1, 2, 31) Arr88(-1, 2,-31) arr88b.negate) arr88b arr88bArr88(lambda x: x, Lambda x: x arr88b.apply(lambda f: f(1)) 1, lambda x: x 2]) ArrB8(I-4.8, 5.5, 0.0) Arr88([1, 2, 31) YOUR CODE HERE return YOUR CODE HERE return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
