Computers and Technology

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.
If you wish to use any of the functions from the previous part, you will find that the simplest approach at this time is to copy your funcs. py file to this directory. To do so, from within the funcs_objects directory, type cp ../funcs/funcs. py . (the . (dot) at the end of that command is important; it signifies the current directory as the destination of the copy).
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. If an object is to be returned, then you will need to assign the result to a variable and test each field independently.
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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:00, lilkit
Is the following sentence true or false? during meiosis, the two alleles for each gene stay together.
Answers: 3
image
Computers and Technology, 23.06.2019 04:00, ittmanny6138
Laire writes a letter to her grandmother, in which she describes an amusement park she visited last week. she adds pictures of that place in her letter. which feature of a word processing program will claire to remove unwanted parts of the pictures?
Answers: 3
image
Computers and Technology, 23.06.2019 19:00, jacobbecker99
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u. s. 483 (1954). b. international shoe co. v. washington, 326 u. s. 310 (1945) c. haynes v. gore, 531 u. s. 98 (2000). d. international shoe co. v. washington, 14 u. s. code 336.
Answers: 1
image
Computers and Technology, 24.06.2019 08:50, bo4isbad
Write a program that will compute the volume of ice cream served in a cone. as you can see in the diagram below, the ice cream is served as a hemisphere of frozen deliciousness on top of a cone, which is also packed with frozen deliciousness. thus, the total volume of ice cream sold is the volume of the hemisphere plus the volume of the cone. the example shows an ice cream cone in which the hemisphere and cone have a radius of 10 inches and the cone has a height of 15 inches. your program must instead prompt for these two values, which are taken from the keyboard as integers: • the hemisphere/cone radius in inches, and
Answers: 3
Do you know the correct answer?
Functions on Structured Data This part will be executed with: python funcs_objects tests. py
...

Questions in other subjects:

Konu
Mathematics, 10.03.2020 00:22
Konu
Biology, 10.03.2020 00:22