
Concept explainers
class Vector3D:
def __init__(self, x, y, z):
# TODO: Create a routine that saves the vector
# <x, y, z> into this Vector3D object.
pass
def __add__(self, other):
# TODO: Create a routine that adds this vector with Vector3D other
# and returns the result as a Vector3D object
return None
def __neg__(self):
# TODO: Create a routine that returns the negative (opposite) of
# this vector as a Vector3D object
return None
def __sub__(self, other):
# TODO: Create a routine that subtracts this vector with Vector3D other
# and returns the result as a Vector3D object
return None
def __mul__(self, other):
# TODO: Create a routine that multiplies this vector with other
# depending on its data type, and returns the result as a
# Vector3D object. other can either be an integer
# scalar or a Vector3D object.
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()

![1
3 class Vector3D:
def init _(self, x, y, z):
# TODO: Create a routine that saves the vector
4
6.
<x, y, z> into this Vector3D object.
pass
8
def add_(self, other):
# TODO: Create a routine that adds this vector with Vector3D other
and returns the result as a Vector3D object
10
11
%23
12
13
return None
14
15
def -neg__(self):
16
= TODO: Create a routine that returns the negative (opposite) of
17
%23
this vector as a Vector3D object
18
19
return None
20
def -_sub__(self, other):
# TODO: Create a routine that subtracts this vector with Vector3D other
%23
21
22
23
and returns the result as a Vector3D object
24
25
return None
26
27 Y
def mul_(self, other):
# TODO: Create a routine that multiplies this vector with other
28
29
%23
depending on its data type, and returns the result as a
Vector3D object. other can either be an integer
scalar or a Vector3D object.
30
%23
31
32
33
return None
34
35 vdef main():
36
testcases = int(input ())
37
for t in range (testcases) :
line in = input().split()
op = line_in [0].strip()
vec vals [int (x) for x in line in[1:])
38
39
40
41
42
43
# TODO: a Write routine that processes a line in the input
- string
- operation to do with the provided vectors
- can only be one from the set: {add, sub, neg, mul_s, mul}
44
# op
45
%23
46
47
# vec vals - list of integers
- numbers that follow the op in the input line
- can only have a length of 3, 4, or 6
48
%3D
49
%23
50
51 vif -_name_ == '-_main__':
main()
52](https://content.bartleby.com/qna-images/question/a3cf655d-3bdc-4013-8c1f-5d6d56ea7228/219f4d51-9c6a-46f2-a124-034978de950c/3iuj9rc_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images

- In Java please,arrow_forwardAjva.arrow_forwardPlease create a Java class that has the following data attributes and methods: private int count - number of customers in the array private customer Record[] data - array of customerRecord objects public customer List() constructor that should initialize memory for data array and count value public void getCustomerList(String fileName) - reads a file call fileName which is a text file containing lines (records) of customer data. This method fills the data array with the records from the file. The file will not have more than 100 records and will have the following format (where customer Number is an integer, firstName and lastName are Strings, and balance is a float: customerNumber firstName lastName balance public customerRecord getCustomer(int customerNumber) - returns the object corresponding to the customer with customerNumber. If the customer number is not in the array, return null. public void enter CustomerRecord(customerRecord new_record)…arrow_forward
- Every data structure that we use in computer science has its weaknesses and strengthsHaving a full understanding of each will help make us better programmers!For this experiment, let's work with STL vectors and STL dequesFull requirements descriptions are found in the source code file Part 1Work with inserting elements at the front of a vector and a deque (30%) Part 2Work with inserting elements at the back of a vector and a deque (30%) Part 3Work with inserting elements in the middle, and removing elements from, a vector and a deque (40%) Please make sure to put your code specifically where it is asked for, and no where elseDo not modify any of the code you already see in the template file This C++ source code file is required to complete this problemarrow_forwardA vector in Matlab has magnitude and direction is an array with only one column or one row is a table of numbers contains at most three numbers, one for each dimension. When adding two arrays in Matlab the arrays only need to have the same number of elements the arrays must have the exact same size and shape you need to put a period in front of the plus sign both b and c are true When combining a scalar c to an array A with a command like c + A Matlab adds the c to every element in A an error is displayed because the dimensions are different the result will be different than the command A + carrow_forwardvWhat happens when an object such as an array is no longer referenced by a variable?arrow_forward
- shapes = [{'type': 'circle', 'x': 300, 'y': 300, 'radius': 100, 'color': 'cyan'},{'type': 'circle', 'x': 300, 'y': 300, 'radius': 10, 'color': 'white'},{'type': 'rectangle', 'x1': 500, 'y1': 500, 'x2': 550, 'y2': 580, 'color': 'green'},{'type': 'line', 'x': 0, 'y': 0, 'a': 100, 'b': 300, 'color': "black", 'width': 7},{'type': 'point', 'x': 200, 'y': 50, 'color': 'black'},{'type': 'point', 'x': 205, 'y': 50, 'color': 'black'},{'type': 'point', 'x': 210, 'y': 50, 'color': 'black'},{'type': 'triangle', 'x': 500, 'y': 100, 'a': 600, 'b': 100, 'c': 550, 'd': 200, 'color': 'yellow'},{'type': 'oval', 'x': 100, 'y': 100, 'a': 400, 'b': 400, 'color': 'red'},{'type': 'text', 'x': 500, 'y': 50, 'message': 'hello world!', 'color': 'blue'}] I'd like to take this list and write it to a new txt file. Ignoring the ':' , {}, and words within quotation marks. so the txt file created would look like this: circle, 300,300, 100, cyancircle, 300,300, 10, whiterectangle, 500,500, 550,580, greenline, 0,0,…arrow_forwardConsider the following code: int main (void) ( std::vector intVector(0); } intVector.pushback(1); intVector.pushback(2); intVector.pushback(3); // Vector of 0 ints a. Draw the memory layout of intVector when the code is finished. b. Where in memory is intVector allocated?arrow_forwardIn Java Assignment 5B : Maze Game! 2D Arrays can be used to store and represent informationabout video game levels or boards. In this exercise, you will use this knowledge tocreate an interactive game where players attempt to move through a maze. You willstart by creating a pre-defined 2D array with the following values:{"_","X","_","X","X"}{"_","X","_","X","W"}{"_","_","_","X","_"}{"X","X","_","_","_"}{"_","_","_","X","X"}You will then set the player (represented by “O”) at index 0, 0 of the array, the top-leftcorner of the maze. You will use a loop to repeatedly prompt the user to enter adirection (“Left”, “Right”, “Up”, or “Down”). Based on these directions, you will try tomove the player.• If the location is valid (represented by “_”), you will move the player there• If the location is out of bounds (e.g. index 0, -1) or the command is invalid, youwill inform the player and prompt them to enter another direction• If the location is a wall (represented by “X”), you will tell the…arrow_forward
- JAVA CODEarrow_forwardClasses, Objects, Pointers and Dynamic Memory Program Description: This assignment you will need to create your own string class. For the name of the class, use your initials from your name. The MYString objects will hold a cstring and allow it to be used and changed. We will be changing this class over the next couple programs, to be adding more features to it (and correcting some problems that the program has in this simple version). Your MYString class needs to be written using the .h and .cpp format. Inside the class we will have the following data members: Member Data Description char * str pointer to dynamic memory for storing the string int cap size of the memory that is available to be used(start with 20 char's and then double it whenever this is not enough) int end index of the end of the string (the '\0' char) The class will store the string in dynamic memory that is pointed to with the pointer. When you first create an MYString object you should…arrow_forwardWhat is the difference between the size and capacity of a vector?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





