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()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

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: 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.
Transcribed Image Text: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.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY