Ask Question
13 December, 18:40

Write a function with local functions that calculates the volume, side areas, and total surface area of a box based on the lengths of the sides. It will have 3 inputs: the length, width, and height of the box. There will be no outputs since it will simply print the results to the screen.

+2
Answers (1)
  1. 13 December, 19:04
    0
    def calcBox (l, w, h) : vol = l*w*h print ("Volume is : " + str (vol)) sideArea1 = h*w sideArea2 = h*w sideArea3 = h*l sideArea4 = h*l sideArea5 = w*l sideArea6 = w*l print ("Side Area 1: " + str (sideArea1)) print ("Side Area 2: " + str (sideArea2)) print ("Side Area 3: " + str (sideArea3)) print ("Side Area 4: " + str (sideArea4)) print ("Side Area 5: " + str (sideArea5)) print ("Side Area 6: " + str (sideArea6)) surfAreas = 2*h*w + 2*h*l + 2*w*l print ("Total surface areas is: " + str (surfAreas)) calcBox (5, 8, 12)

    Explanation:

    Firstly, create a function calcBox that takes three inputs, l, w, and h which denote length, width and height, respectively.

    Apply formula to calculate volume and print it out (Line 2-3).

    Since there are six side areas of a box, and we define six variables to hold the calculated value of area for one side respectively (Line 5 - 10) and print them out (Line 11-16).

    Apply formula to calculate surface areas and print it out (Line 18 - 19)

    At last test the function (Line 21).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a function with local functions that calculates the volume, side areas, and total surface area of a box based on the lengths of the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers