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, 21.06.2019 18:00
What ordering of tcp flags makes up the three-way handshake?
Answers: 2
question
Computers and Technology, 22.06.2019 00:40
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin.get(mychar1); 18. cin> > mychar2; 19. getline(cin,mystring2); mystring2 20. 21. 22. cout<
Answers: 1
question
Computers and Technology, 22.06.2019 06:20
In what kind of attack can attackers make use of millions of computers under their control in an attack against a single server or network availability confidentiality integrity identity automated attack software? those who wrongfully disclose individually identifiable health information can be fined up to what amount per calendar year? single most expensive malicious attack hipaa what are script kiddies? advanced persistent threat security manager security engineer what level of security access should a computer user have to do their job what process describes using technology as a basis for controlling the access and usage of sensitive data? cybercriminal
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Arecipients list has been loaded into a document. which commands should be clicked in order to filter the list so that letters will not be printed for recipients who live in a certain state? mailings tab, start mail merge, select recipients, type new list, then insert only contacts from the desired states mailings tab, rules, select recipients, use existing list, then choose a recipients list that includes only contacts in certain states mailings tab, select recipients, use existing list, rules, fill in, then type in certain states mailings tab, rules, skip record select β€œstate” under field name, then type in the state name under β€œequal to”
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
Chemistry, 15.01.2021 20:10
question
Engineering, 15.01.2021 20:10
question
Mathematics, 15.01.2021 20:10
Questions on the website: 13722361