Ask Question
4 March, 06:14

Write a class that has several functions related to an Equilateral Triangle. The constructor should accept a one parameter for the length (which is the same for all 3 sides in an equilateral triangle).

+4
Answers (1)
  1. 4 March, 10:13
    0
    class EqTri:

    def __init__ (self, length=0.0):

    self. length = length

    def getArea (self):

    return (3**0.5 / 4) * self. length * * 2

    def getPerimeter (self):

    return 3 * self. length

    def __str__ (self):

    return 'EqTri (Area:' + str (self. getArea ()) + ') '

    def __float__ (self):

    return float (self. getArea ())

    t = EqTri (5)

    print ('Area = ' + str (t. getArea ()))

    print ('Perimeter = ' + str (t. getPerimeter ()))

    print (t)

    print (float (t))
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a class that has several functions related to an Equilateral Triangle. The constructor should accept a one parameter for the length ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers