Question
Using python 3: Do not change the tests. Write the body of the distFromOrigin method. class...
using python 3:
Do not change the tests. Write the body of the distFromOrigin method.
class Point:
def __init__(self, initX, initY):
""" Create a new point at the given coordinates """
self.__x = initX
self.__y = initY
def getX(self):
""" Get its x coordinate """
return self.__x
def getY(self):
""" Get its y coordinate """
return self.__y
def __str__(self):
""" Return a string representation of self """
return "({}, {})".format(self.__x, self.__y)
def distFromOrigin(self):
""" Return the distance between self and (0,0) """
return 0
if __name__ == "__main__":
import test
a = Point(-4,3)
test.testEqual(a.distFromOrigin(), 5)
b = Point(1,1)
test.testEqual(b.distFromOrigin(), 2**0.5)
Answers
class Point: def __init__(self, initX, initY): """ Create a new point at the given coordinates """ self.__x = initX self.__y = initY def getX(self): """ Get its x coordinate """ return self.__x def getY(self): """ Get its y coordinate """ return self.__y def __str__(self): """ Return a string representation of self """ return "({}, {})".format(self.__x, self.__y) def distFromOrigin(self): """ Return the distance between self and (0,0) """ return ((self.__x*self.__x)+(self.__y*self.__y))**(0.5) if __name__ == "__main__": import test a = Point(-4,3) test.testEqual(a.distFromOrigin(), 5) b = Point(1,1) test.testEqual(b.distFromOrigin(), 2**0.5)
Similar Solved Questions
1 answers
If an organism's diploid number is 12, what will its haploid number be?
If an organism's diploid number is 12, what will its haploid number be?...
1 answers
How does the total energy change when a falling rock hits the ground
how does the total energy change when a falling rock hits the ground?...
1 answers
Problem 5-24 Break-Even and Terget Profit Analysis [LOS-5, LO5-6) tWorks sells a large variety of tee...
Problem 5-24 Break-Even and Terget Profit Analysis [LOS-5, LO5-6) tWorks sells a large variety of tee shirts and sweatshirts. Steve Hooper, the owner, is thinking of expanding his sales by hiring high school students, on a commission basis, to sell sweatshirts bearing the name and mascot of the loca...
1 answers
QUESTION 19 4 points Customer-oriented promotion gives customers a reason to come to the point of...
QUESTION 19 4 points Customer-oriented promotion gives customers a reason to come to the point of purchase and request the product. This process represents which of the following types of activities. o push promotion O pull promotion O horizontal promotion O vertical promotion...
1 answers
If you were the U.S. President, under what circumstances would you drastically raise import tariffs for...
If you were the U.S. President, under what circumstances would you drastically raise import tariffs for a particular product or for imports from a particular country? Under what circumstances would you enact an embargo? What are some likely impacts on the U.S. industry for that product and the indus...
1 answers
Which one of the following answers is correct? If this null hypothesis H0: B1 = B2...
Which one of the following answers is correct? If this null hypothesis H0: B1 = B2 = B3 = 0 is rejected, the interpretation is: a. There is no linear relationship between Y and any of the 3 independent variables b. There is a regression relationship between Y and at least one of the 3 independent va...
1 answers
Sample Hypotheses 1. If the rate of skin cancer occurrence is related to exposure to ultraviolet...
Sample Hypotheses 1. If the rate of skin cancer occurrence is related to exposure to ultraviolet light, then people with a high exposure to UV light will have a higher frequency of skin cancer. Independent variable - Dependent variable - Confounding variable - 2. If the color of the leaves on a tree...
1 answers
What if the patient is hypervolemic or hypovolemic? If so, what data supports this? What effect...
What if the patient is hypervolemic or hypovolemic? If so, what data supports this? What effect do you see on the patient’s vitals from them being hyper or hypovolemic? What illnesses can put a patient at risk for a fluid and electrolyte disturbance? How so? If the patient has Mg, K, or Ca val...
1 answers
PRINCIPLES MANAGEMENT Emirates islamic bank (EIB) focused to the next level of success, expanding the reach...
PRINCIPLES MANAGEMENT Emirates islamic bank (EIB) focused to the next level of success, expanding the reach of the organization on a local and regional level. EIB are driven to building our organization on the two pillars of Personal and Commercial Banking, which will serve as the engine for our fut...
1 answers
You are interested in thymol in mouthwash. The manufacturer lists the active ingredients as thymol (0.064%),...
You are interested in thymol in mouthwash. The manufacturer lists the active ingredients as thymol (0.064%), menthol (0.042%), eucalyptol (0.092%) and methyl salicylate. The inactive ingredients include caramel, water and alcohol (21.6%) in addition to sodium benzoate, color, poloxamer 407 and benzo...
1 answers
Explain Both and Answer Thank You The eyeless trait is recessive in Drosophila. One of the...
Explain Both and Answer Thank You The eyeless trait is recessive in Drosophila. One of the offspring of a cross between heterozygote (Ee) parents has eyes. How would you determine whether this fly is homozygous (EE) or heterozygous (Ee)? Cross it with a fly that has eyes but an unknown genotype ...
1 answers
The speed of particle with 9e C charge is 7.6x104 m/s, and the magnitude of the...
The speed of particle with 9e C charge is 7.6x104 m/s, and the magnitude of the magnetic force is 15.4 x10-15 N. What is the magnitude of the magnetic field if the particle is traveling 16º to the field? (Recall e is the magnitude of the charge of an electron.)...
1 answers
6. -14 points SerCP11 6.2.P.028. My Notes + Ask Your Teacher Two objects of masses m...
6. -14 points SerCP11 6.2.P.028. My Notes + Ask Your Teacher Two objects of masses m = 0.50 kg and m2 = 0.90 kg are placed on a horizontal frictionless surface and a compressed spring of force constant k = 300 N/m is placed between them as in figure (a). Neglect the mass of the spring. The spring is...
1 answers
Show that the matrix is not diagonalizable. 1-42 13 0 02 STEP 1: Use the fact...
Show that the matrix is not diagonalizable. 1-42 13 0 02 STEP 1: Use the fact that the matrix is triangular to write down the eigenvalues. (Enter your answers from smallest to largest.) (11.22) = STEP 2: Find the eigenvectors Xi and X2 corresponding to 1, and 12, respectively. X1 = X2 - STEP 3: Sinc...
1 answers
(1 pt) True False Problem Enter T or F depending on whether the statement is true...
(1 pt) True False Problem Enter T or F depending on whether the statement is true or false. (You must enter T or F True and False will not work.) exists, then the product A-B gives 1. If AX = B represents a system of linear equations and the solution to the system 2. If A and B are both square matri...
1 answers
Chapter 06, Problem 87 Suppose the skateboarder shown in the drawing reaches a height of 1.50...
Chapter 06, Problem 87 Suppose the skateboarder shown in the drawing reaches a height of 1.50 m above the right side of the semicircular ramp. He then makes an incomplete midair turn and ends up sliding down the right side of the ramp on his back. When the skateboarder reaches the bottom of the ramp...
1 answers
Hello, Can you please check my work and give an explanation for any part that is...
Hello, Can you please check my work and give an explanation for any part that is not correct? Thank you. The Diversified Portfolio Corporation provides investment advice to customers. A condensed income statement for the year ended December 31, 2021, appears below: Service revenue Operating expen...
1 answers
2 points (Extract Giles Inc. Giles Inc., manufactures high quality golling equipment Giles assigns overhead to prod...
2 points (Extract Giles Inc. Giles Inc., manufactures high quality golling equipment Giles assigns overhead to products based on machine hours. At the beginning of the current year, estimated overhead costs were 5620750 and estimated machine hours were 65.000 During the year, 54.000 machine hours we...