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:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
question
Engineering, 04.07.2019 18:20
Air is compressed isentropically from an initial state of 300 k and 101 kpa to a final temperature of 1000 k. determine the final pressure using the following approaches: (a) approximate analysis (using properties at the average temperature) (b) exact analysis
Answers: 1
question
Engineering, 04.07.2019 18:20
Atank with constant volume contains 2.27 kg of a mixture of water phases (liquid-vapor). in the initial state the temperature and the quality are 127 °c and 0.6, respectively. the mixture is heated until the temperature of 160 oc is reached. illustrate the process in a t-v diagram. then, determine (1) the mass of the vapor in kg at the initial state, (2) the final pressure in kpa.
Answers: 3
question
Engineering, 04.07.2019 19:10
How to increase the thermal officiency of an ideal simple rankino cycle? among these methods, which one is the best and why?
Answers: 2
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
Mathematics, 19.04.2021 07:20
question
Mathematics, 19.04.2021 07:20
question
History, 19.04.2021 07:20
question
Mathematics, 19.04.2021 07:20
question
Advanced Placement (AP), 19.04.2021 07:20
Questions on the website: 13722362