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
An air compression refrigeration system is to have an air pressure of 100 psia in the brine tank and an allowable air temperature increase of 60°f for standard vapor compression cycle temperatures of 77 f entering the expansion cylinder and 14 f entering the compression cylinder, calculate the coefficient of performance a. 2.5 b 3.3 c. 4.0 d. 5.0
Answers: 3
question
Engineering, 04.07.2019 18:20
Select any two (2) areas of applications of chain-drive. (clo4) a)-permanent lubrication necessary b)-hydraulic forklift truck operation c)-rigging and heavy moving materials d)-relatively high maintenance costs e)-costlier than belt drives
Answers: 2
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
question
Engineering, 04.07.2019 19:10
For a process taking place in a closed system containing gas, the volume and pressure relationship is pvi-constant. -1.5 bar, the process starts with initial conditions, pi = =0.03 m3 and ends with final volume, v2-0.05 m3 determine the work done by the gas.
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
Medicine, 01.12.2019 03:31
Questions on the website: 13722363