Python Activity (see pic about class Vector3D): Code for copy: class Vector3D: def __init__(self, x, y, z): # def __add__(self, other): # return None def __neg__(self): # return None def __sub__(self, other): # return None def __mul__(self, other): # return None def main(): testcases = int(input()) for t in range(testcases): line_in = input().split() op = line_in[0].strip() vec_vals = [int(x) for x in line_in[1:]] # TODO: a Write routine that processes a line in the input # op - string # - operation to do with the provided vectors # - can only be one from the set: {add, sub, neg, mul_s, mul} # vec_vals - list of integers # - numbers that follow the op in the input line # - can only have a length of 3, 4, or 6 if __name__ == '__main__': main()
Python Activity (see pic about class Vector3D):
Code for copy:
class Vector3D:
def __init__(self, x, y, z):
#
def __add__(self, other):
#
return None
def __neg__(self):
#
return None
def __sub__(self, other):
#
return None
def __mul__(self, other):
#
return None
def main():
testcases = int(input())
for t in range(testcases):
line_in = input().split()
op = line_in[0].strip()
vec_vals = [int(x) for x in line_in[1:]]
# TODO: a Write routine that processes a line in the input
# op - string
# - operation to do with the provided
# - can only be one from the set: {add, sub, neg, mul_s, mul}
# vec_vals - list of integers
# - numbers that follow the op in the input line
# - can only have a length of 3, 4, or 6
if __name__ == '__main__':
main()
![PYTHON Activity: Class Vector3D
Input Format
The first line of the input is an integer T denoting the number of lines that will follow. Each line then consists
of a variable number of elements separated by a space. The line starts with a word op denoting what
operation to do. The operations will only be any of the following: add, sub, neg, mul_s, mul.The next
elements will be space-separated numbers.
Input (Testcase):
5
add 1 2 3 4 5 6
sub 1 2 3 4 5 6
mul s 1 2 3 -2
mul 1 2 3 4 5 6
For add, sub, and mul, op will be followed by six numbers a, ay az bz by bz corresponding to the
coordinates of vectors a and b respectively.,
neg 3 3 3
For mul_s,op will be followed by four numbers ag ay az s corresponding to the coordinates of the vector a
and a scalar s, respectively.
Expected Output
For neg, op will be followed by three numbers az ay az corresponding to the coordinates of the vector a.
5 7 9
-3 -3 -3
Constraints
-2 -4 -6
4 10 18
Input Constraints
-3 -3 -3
T< 100
A = (ap, ay, az) E Z3, {a; € Z: [a;| < 10°}
op € {add, sub, neg, mul, mul_s}
Max running time of code should be < 5 seconds for each test input.
You can assume that all of the inputs are well-formed and are always provided within these constraints. You
are not required to handle any errors.
Functional Constraints
You are required to create a class named Vector3D with an __init__(self, x, y, z) function. It should
also have the following special functions: _add__,
sub__, __neg__, -_mul__. Failure to do so will mark
your code with a score of zero.
Output Format
The output consists of T lines, with each line i corresponding to the 3D vector a;g aiy aig that is the result
of performing the operation requested on that line.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F278dfba8-a3e9-49d1-ad4c-f59a160a3145%2F0aef83e7-3617-48c7-90c7-9fcb029e674f%2Frg1nt3m_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)