Ask Question

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. 29 March, 21:01
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers