given class triangle, complete the program to read and set the base and height of triangle1 and triangle2, determine which triangle's area is smaller, and output the smaller triangle's info, making use of triangle's relevant methods.

Respuesta :

The code for determining the area of the triangle is:

class Triangle:

def __init__(A):

A.base = 0

A.height = 0

def set_base(A, user_base):

A.base = user_base

def set_height(A, user_height):

A.height = user_height

def get_area(A):

area = 0.5 * A.base * A.height

return area

def print_info(A):

print('Base: {:.2f}'.format(A.base))

print('Height: {:.2f}'.format(A.height))

print('Area: {:.2f}'.format(A.get_area()))

if __name__ == "__main__":

triangle1 = Triangle()

triangle2 = Triangle()

# TODO: Read and set base and height for triangle1 (use set_base() and set_height())

# TODO: Read and set base and height for triangle2 (use set_base() and set_height())

# TODO: Determine smaller triangle (use get_area())

print('Triangle with smaller area:')

# TODO: Output smaller triangle's info (use print_info())

Traingle is a type of polygon, the name itself days, tri means three, angles.

So, in a triangle, there will be three vertices, three sides and three angles.

The vertex of a triangle is a point where any two of the sides of a triangle meet.

The altitude of a triangle is the perpendicular length of the triangle, it is also called as height of the triangle. It is drawn perpendicular on the base of the triangle to the apex.

Base of a triangle is that particular side of the triangle on which an altitude is drawn.

For writing the code, we will put the input like only values, like 6.0, 7.0, 11.0 etc.

The first value will denote base of first triangle, second will denote height  of first triangle and third will denote base of second triangle and fourth value denotes height of second triangle/

Let us assume that,

Triangle with smaller area:

Base: 4.00

Height: 5.00 = [4.00*5.00]2 = 10.00

For more questions on Area of triangle by Python

https://brainly.com/question/25327642

#SPJ4

ACCESS MORE