Final answer:
To create a module (library) named MyTriangle containing the required functions, you can define the functions within a Python file. The module should include the isValid() function, which checks if the sum of any two sides is greater than the third side, and the area() function, which calculates and returns the area of the triangle using the given formula. The main function of the program reads three sides for a triangle, checks if the input is valid using the isValid() function, and if valid, computes and displays the area of the triangle.
Step-by-step explanation:
To create a module (library) named MyTriangle that contains the required functions, you can define the functions within a Python file named MyTriangle.py. Here is an example implementation:
import math
def isValid(side1, side2, side3):
# Returns True if the sum of any two sides is greater than the third side
return side1 + side2 > side3 and side1 + side3 > side2 and side2 + side3 > side1
def area(side1, side2, side3):
# Returns the area of the triangle
s = (side1 + side2 + side3) / 2
return math.sqrt(s * (s - side1) * (s - side2) * (s - side3))
def main():
# Read three sides for a triangle
side1 = int(input('Enter side1: '))
side2 = int(input('Enter side2: '))
side3 = int(input('Enter side3: '))
# Check if input is valid
if isValid(side1, side2, side3):
# Compute and display the area
triangle_area = area(side1, side2, side3)
print('The area of the triangle is:', triangle_area)
else:
print('Invalid input. The sides do not form a valid triangle.')
# Call the main function
main()
This code defines a module named MyTriangle that contains the functions isValid() and area(). It also includes a main() function that reads three sides for a triangle, checks if the input is valid using the isValid() function, and computes the area using the area() function.