Ask Question
3 August, 06:06

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).

+2
Answers (1)
  1. 3 August, 07:50
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers