subject

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: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Annie is creating a corporate report for a company’s annual meeting. in the report, she wants to add the signature of various department heads. which device can annie use to capture signatures to include in the report? a. printer b. monitor c. e-reader d. digitizing tablet
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 23.06.2019 12:40
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
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
Mathematics, 24.12.2020 01:50
question
Physics, 24.12.2020 01:50