Question: Python module that contains the following: A custom class named LandMammal that holds data facts regarding the world's largest land mammals. A main() function that

Python module that contains the following:

  • A custom class namedLandMammalthat holds data facts regarding the world's largest land mammals.
  • Amain()function that contains unit test cases for the LandMammal class.

TheLandMammalclass should implement a constructor that sets up the following instance variables:

  • name (string)
  • minimum mass in pounds (int)
  • maximum mass in pounds (int)

Hint.Implement a constructor with__init__()

You will also need to provide a method namedmass_range()to calculate and return the following attribute:

  • calculate the range of mass and return an int.

Themain()function should create test cases for the following:

  • the constructor
  • themass_range()method

Invoke themain()function with the final statements in your module making sure that unit test code only runs when the module is run by itself and not when the module is imported by another program.

Hint.Include the following statements at the end of your module.

if__name__=='__main__':

main()

When this program is run directly (rather than having been imported), the console session should contain the unit testing output and should look like this:

Unit testing output follows... Testing the constructor: African elephant 10000 24000 Testing the mass_range method: 14000 

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 Programming Questions!