
In Python please help with the following:
a) Write a class in Python called Vector2d whose initializer receives two numbers: x,y.
Define an instance method called translateby that receives two numbers: dx and dy and translates the vector by dx and dy. Translating vector v by dx and dy makes the vector's x and y incremented by dx and dy, respectively.
For example: (1, 2) translated by 3, and 4 results in (4,6).
Define a static method called sum that receives two
vector whose value equals the sum of the two vectors.
B) Test your code by implementing the following:
• Create a vector v1, instantiate it with (1, 2).
• Create a vector v2, instantiate it with (2, 4).
• Calculate the sum of the two vectors in v3.
• Translate v3 by 1 and 2.
• Print v3's coordinates. It prints 4, 8.

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

- 1. Copy constructor to create a new bag using a bag passed in. However, please note that the order in which this constructor stores the items is the reverse of the original order (in which the items appear in the passed-in bag). 2. Function addVector, which takes a vector as the only parameter, to add the entries from the vector to the new bag. 3. Function removelastThree, which takes an item as the only parameter, to remove the last three occurrences of the item in the bag. It is OK to make assumptions. Please state our assumptions, if any. Please explain in detail how each step works and what the new bag contains after each of the steps is executed. - Please use linked Nodes diagrams in our answer. - Please use the data below in our explanation. 1. Passed-in bag: 2. Passed-in vector: 'e', 'n', 'g', ",'n', 'e', 'e', 'r 'e', ", 'e', 'c', 't, 'r', 'i, 'c', 'a', 'I' 3. Passed-in item: 'e' Copy constructor (reverse order) function addVectorarrow_forwardIn c++ iv read from a text file containing integers Example 11,1 22, 3 12, 4 And stored each colum in a vector vectorx and vectory How can i make a class for x integers and class for y integers I will use this classes to compare these x and y integersarrow_forwardThere are two tasks to this assignment. Task 1 Currently you are using composition by creating an instance of a vector / ArrayList inside your AddressBook. This works fine but if we really think about it, an AddressBook is a collection like a stack or a queue or a vector for that matter. Your task is to: C++ derive AddressBook from vector. In other words, use the vector as a base class and derive AddressBook from it. This means that you will need to remove the Vector from the private section of your class. Java derive AddressBook from ArrayList. In other words, use the ArrayList as a base class and derive AddressBook from it. This means that you will need to remove the ArrayList from the private section of your class. You are going to have to make some fundamental changes to your AddressBook so that you are using the vector / ArrayList functionality to store and retrieve people. In other words, you should be accessing the ArrayList / vector using this. C++ people, don’t forget you…arrow_forward
- Write a C++ program that allows two players to play the tic-tac-toe game. Your program must contain the struct TicTacToe to implement a TicTacToe object. Include a 3-by-3 two-dimensional array, as a member variable, to create the board. If needed, include additional member variables. Some of the operations on a TicTacToe object are Printing the current board Getting a move Checking if a move is valid Determining the winner after each move.Add additional operations as needed.arrow_forward3. In the C++ language, write a function that takes a vector as the parameter and reverses the vector. You are only given the vector as a parameter and test the function for a sample vector for any datatype of your choice. Do, not use any extra memory and reverse the given vector only.arrow_forwardWrite a C#program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string) ClassRegistration -…arrow_forward
- Write in c++ pleasearrow_forwardWrite In c++arrow_forwardDefine a function named GetWordFrequency that takes a vector of strings and a search word as parameters. Function GetWordFrequency() then returns the number of occurrences of the search word in the vector parameter (case insensitive). Then, write a main program that reads a list of words into a vector, calls function GetWordFrequency() repeatedly, and outputs the words in the vector with their frequencies. The input begins with an integer indicating the number of words that follow. Ex: If the input is: 5 hey Hi Mark hi mark the output is: hey 1 Hi 2 Mark 2 hi 2 mark 2 Hint: Use tolower() to set the first letter of each word to lowercase before comparing. The program must define and use the following function:int GetWordFrequency(vector<string> wordsList, string currWord)arrow_forward
- In C++,define a vector object and initialize it with 3 values and then define an iterator that points to elements of this object, then ask the user to enter 3 more values and then add them to the previous vector and then print all elements in the vector.arrow_forwardEvery 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_forwardWrite a C++ program define a vector object and initialize it with 3 values and then define an iterator that points to elements of this object, then ask the user to enter 3 more values and then add them to the previous vector and then print all elements in the vector.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





