Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help in Python version 3.5 12-i (The Triangle class Design a class named Tr

ID: 3582146 • Letter: N

Question

Need help in Python version 3.5

12-i (The Triangle class Design a class named Triangle that extends the Geometric0bject class. The Triangle class contains: Three float data fields named side, side2, and side3 to denote the three sides of the triangle. A constructor that creates a triangle with the specified sidel, side2, and side3 with default values 1.0. The accessor methods for all three dala fields. A method named getAreaO that retums the area ofthis triangle. A method named getPerimeterO that returns the perimeter of this triangle. A method named str. O that retums a string description for the triangle.

Explanation / Answer

/* Finding Area and Perimeter of triangle in python programming */

def area(x, y, z):

    # calculate the sides

    s = (x + y + z) / 2

    # calculate the area

    area = (s*(s-x)*(s-y)*(s-z)) ** 0.5

    return area

def perimeter(x, y, z):

    # Calculate the perimeter

    peri = x + y + z

    return peri

def main():  

    s1 = float(input('Enter first side: '))

    s2 = float(input('Enter second side: '))

    s3 = float(input('Enter third side: '))

    print ("Area is:", area(s1, s2, s3)) // calling to find area of triangle

    print ("Perimeter is:", perimeter(s1, s2, s3))                                    // calling to find perimeter of triangle

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote