Question: Write a class, triangle_area, that will contain 3 attributes. The attributes, base, and height will be integers. The other parameter is right is a boolean

 Write a class, triangle_area, that will contain 3 attributes. The attributes,

Write a class, triangle_area, that will contain 3 attributes. The attributes, base, and height will be integers. The other parameter is right is a boolean and will define whether the triangle is a right triangle or not. All attributes should be defined when an instance of the class is created. The is_right attribute should have a default value, False. ( 8 points) The class should also contain two methods. The first method, hypotenuse, should determine the length of the hypotenuse if the instance is a right triangle. Otherwise, the method will print a message stating that the instance is not a right triangle. ( 7 points) The other method, area, will return the area of the triangle, given the base and height of its instance. However, the area method will only return a value if both base and height are positive integers and are not 0 . If these conditions aren't met, the area method will return 0 . (6 points) Create two instances of this class. One of those instances should be a right triangle with a height of 4 , and a base of 3 . The second instance should be a regular triangle with a height of 10 , and a base of 4 . Declare the hypotenuse and area methods on both of these

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!