Question: 1. The program first asks for total number of triangles 'n' user wants to calculate area of. 2. Then using a loop, the program

1. The program first asks for total number of triangles 'n' user wants to calculate area of. 2. Then using a 

1. The program first asks for total number of triangles 'n' user wants to calculate area of. 2. Then using a loop, the program will ask to enter three sides for each triangle. The loop runs 'n' number of times. 3. Once three sides are provided for one triangle, the program calls a user defined function 'calculate_area' which calculates the 'area' and returns the value to the main function. 4. The main function prints the area of the triangle using str.format() and appends the 'area' to a list named 'areas'. 5. At the end of the program, it prints the largest area from the 'areas' list. max() is a built-in function which takes a list of numbers as parameter and returns the largest number from the list. 6. For this lab, you are expected to define two user-defined functions: a. calculate_area(): to calculate the area of the triangle. This function will take three sides of a triangle as parameter and returns the area of the triangle. To calculate the area of the triangle you use the following given formula. For area calculation you need to use exponential operator as x* *0.5 to calculate square root of x. b. main() function: This function organizes main functionality of the code. i. It will ask for total number of triangles 'n', ii. run a loop for 'n' number of times, iii. ask for three sides for each triangle, iv. call calculate_area() function, v. prints the 'area' returned by calculate_area(), vi. append the 'area' to 'areas' list and vii. then at the end of the program prints the largest area Heron's Formula S = A+B+C Area =S(S-A)(S-B) (S-C) C malwarehouse.com

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import math def calculateareaa b c Function that takes 3 sides of the triangle and calculates and re... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!