Question: 11.26 3-D point class For this lab you will create a custom class that implements a point in 3-D space. Name your class 'pt3d'. The

 11.26 3-D point class For this lab you will create a

custom class that implements a point in 3-D space. Name your class

11.26 3-D point class For this lab you will create a custom class that implements a point in 3-D space. Name your class 'pt3d'. The class will have three attributes, x,y,z. These x,y,z values should default to zero. Given two instances of the pt3d class a and b, implement methods such that: a+b returns a new pt3d object whose x, y and z values are the sum of the a and b x, y and z values a-b returns the Euclidean distance between points a and b a==b returns true if the x, y and z values of a and b are equal, false otherwise When you call print(a) the printout should be of the format ' You can test and develop your class either from the main block in your program, from another module, or using the python interpreter directly >>> from pt3d import pt3d >>> pi=pt3d (1,1,1) >>> p2=pt3d (2,2,2) >>> print (p1+p2) >>> print (p1-p2) 1.7320508075688772 >>> pl==p2 False >>> p1+p1==p2 True >>> pi==p2+pt3d(-1,-1,-1) True 1 class pt3d: 2 # class implementation goes here 3

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!