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

PLEASE USE PYTHON 3 Create a module named My Triangle that contains the followin

ID: 3820012 • Letter: P

Question

PLEASE USE PYTHON 3

Create a module named My Triangle that contains the following two functions: # Returns true if the sum of any two sides is # greater than the third side def isValid(side1, side2, side3): # Returns the area of the triangle. def area (side1, side2, side3): Write a test program that reads three sides for a triangle and computes the area if the input is valid. Otherwise, it displays that the input is invalid. The formula for computing the area of a triangle is given in Exercise 2.14. Here are some sample runs:

Explanation / Answer

# this is the program to check the triangle sides are valid or not and if valid! then it find the area of triangle.

class MyTriangle:
side1 = float(input("Input the length of side1: "))
side2 = float(input("Input the length of side2: "))
side3 = float(input("Input the length of side3: "))
def isValid(side1, side2, side3):
if (side1 < (side2 + side3)) and (side2 < (side1 + side3)) and (side3 < (side1 + side2)):
   print("The triangle is valid.")
   i = 0
else:
   print("The triangle is not valid.")
def area(side1, side2, side3):
s = (side1 + side2 + side3) / 2
    # calculate the area
    ar = (s*(s-side1)*(s-side2)*(s-side3)) ** 0.5
    print('The area of the triangle is %0.2f' %ar)
  
my.isValid(side1, side2, side3)
if (i == 0):
    my.area(side1, side2, side3)

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