subject
Engineering, 09.04.2020 23:55 izzythe5th

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

Ex: If the input is:

3.0
4.0
4.0
5.0
where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is:

Triangle with larger area:
Base: 4.00
Height: 5.00
Area: 10.00
class Triangle:
def __init__(self):
self. base = 0
self. height = 0

def set_base(self, user_base):
self. base = user_base

def set_height(self, user_height):
self. height = user_height

def get_area(self):
area = 0.5 * self. base * self. height
return area

def print_info(self):
print('Base: {:.2f}'.format(self. base))
print('Height: {:.2f}'.format(self. height))
print('Area: {:.2f}'.format(self. 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 larger triangle (use get_area())

print('Triangle with larger area:')
# TODO: Output larger triangle's info (use print_info())

ansver
Answers: 1

Another question on Engineering

question
Engineering, 04.07.2019 18:10
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:10
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
question
Engineering, 04.07.2019 18:20
For a gate width of 2 m into the paper, determine the force required to hold the gate abc at its location.
Answers: 1
You know the right answer?
Given class Triangle, complete the program to read and set the base and height of triangle1 and tria...
Questions
question
English, 03.02.2021 01:00
question
Biology, 03.02.2021 01:00
question
Arts, 03.02.2021 01:00
Questions on the website: 13722367