Question: Functions on Structured Data This part will be executed with: python funcs_objects tests.py Objects Define a class to represent a two-dimensional point. In the funcs_objects

 Functions on Structured Data This part will be executed with: python

Functions on Structured Data This part will be executed with: python funcs_objects tests.py Objects Define a class to represent a two-dimensional point. In the funcs_objects directory, create a file named objects.py. You will define a class in objects.py to represent the structure of Point objects. The class Point type will need two attributes (named x and y); as before this means that theinit function must take these two arguments (in addition to self) and initialize the attributes within self Define a class to represent a circle. Add this class to the objects.py file. The class Circle type will need two attributes to represent the center point (this will be an object of the Point class) and the radius. Be sure to test yourinit functions by creating objects and verifying that the attributes have been properly initialized. You can place the test cases in the provided funcs_ objects tests.py file. Note that testing the fields of an object that are themselves objects requires a bit more work than one might initially expect. For instance, when verifying that a circle has been properly initialized, you should not compare the center to another Point, but should instead compare each field of the center point (i.e., the center.x and center.y components) to the expected values. Comparing objects directly can be done, but doing so is beyond the scope of this lab. Functions on Point and circle In the funcs_ objects directory create a file named funcs_objects.py. Place your test cases in the provided funcs_ objects tests.py file You must provide at least two test cases for each of these functions. In order to test these functions, you will first need to create an appropriate number of objects and then call the function that you wish to test. distance Write a function, named distance, that takes two arguments of type Point and that returns the Euclidean distance between these two points. circles_overla Write a function, named circles_overlap, that takes two arguments of type circle and that returns True when the circles overlap and False otherwise (consider circles touching at the edge as non-overlapping). You must write this function using a relational operator and without using any sort of conditional. Functions on Structured Data This part will be executed with: python funcs_objects tests.py Objects Define a class to represent a two-dimensional point. In the funcs_objects directory, create a file named objects.py. You will define a class in objects.py to represent the structure of Point objects. The class Point type will need two attributes (named x and y); as before this means that theinit function must take these two arguments (in addition to self) and initialize the attributes within self Define a class to represent a circle. Add this class to the objects.py file. The class Circle type will need two attributes to represent the center point (this will be an object of the Point class) and the radius. Be sure to test yourinit functions by creating objects and verifying that the attributes have been properly initialized. You can place the test cases in the provided funcs_ objects tests.py file. Note that testing the fields of an object that are themselves objects requires a bit more work than one might initially expect. For instance, when verifying that a circle has been properly initialized, you should not compare the center to another Point, but should instead compare each field of the center point (i.e., the center.x and center.y components) to the expected values. Comparing objects directly can be done, but doing so is beyond the scope of this lab. Functions on Point and circle In the funcs_ objects directory create a file named funcs_objects.py. Place your test cases in the provided funcs_ objects tests.py file You must provide at least two test cases for each of these functions. In order to test these functions, you will first need to create an appropriate number of objects and then call the function that you wish to test. distance Write a function, named distance, that takes two arguments of type Point and that returns the Euclidean distance between these two points. circles_overla Write a function, named circles_overlap, that takes two arguments of type circle and that returns True when the circles overlap and False otherwise (consider circles touching at the edge as non-overlapping). You must write this function using a relational operator and without using any sort of conditional

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!