A donut is defined by the following parameter representation: Write a classDonut whose constructor takes over R and r. ̈Consider sensible default values.

A donut is defined by the following parameter representation:

Write a classDonut whose constructor takes over R and r. ̈Consider sensible default values.  If R > r does not apply, then issue a warning to the user and adjust R so that the assurance is fulfilled.Use NumPy to implement the methods for x,y and z.Find out how to calculate the surface area and volume of the donut and implement both methods.The method ___str___ should return a string repr ̈presentation.  Also implement the operator>: one donut should be larger than the other if its volume is larger.Plot the donut on the screen with the method show and the matplotlib (tip: the NumPy function meshgrid is helpful here). 

Set the boundaries for the three axes so that the donut fits well in the plot window, turn off the axis labels and use the OrRd colormap.  Set the viewing height of the plot to 50 and the angle to 30. Use anti-aliasing and a step size of 2. Write a method save that saves the plot to disk.  If the optional parameter filename is not passed, the file should be named donut.png.  Attention: The method should also work without having called show before.  If you could not create the plot from the previous sub-task, you may also save the string representation of the donut as text in the file (default name then donut.txt).

Sample Input & Output Preview

  Solved by verified study co-pilot   All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.
Student review: (11 ratings) 11 out of 11 people found this solution helpful.