Question

In: Computer Science

USING PYTHON Our gift-wrapping department has ran out of wrapping paper. An order for more wrapping...

USING PYTHON

Our gift-wrapping department has ran out of wrapping paper. An order for more wrapping paper needs to be placed. There is a list, generated by the orders department, of the dimensions (length (l), width (w), and height (h)) of each box that needs to be gift wrapped. The list provides the dimensions of each box in inches, l×w×h.

We only need to order exactly as much wrapping paper as is needed and no more.

Fortunately, each package that needs gift wrapping is a cuboid. Which means that you can find the amount of gift-wrapping paper each box requires by finding the total surface area of the cuboid,

surface area=2(lw)+2(wh)+2(hl).

In addition to the surface area of the cuboid, you must also account for loss in the gift-wrapping production process. Each gift-wrapped box requires a loss amount, of wrapping paper, equal to the side of the cuboid with the smallest surface area.

For example

  • A box with dimensions 6x2x3 has l=6, w=2, and h=3, with surface area equal to 2(6⋅2)+2(2⋅3)+2(3⋅6)=72 and loss equal to 2⋅3=6. So, the total amount of wrapping paper needed for the 6x2x3 package is 78 square inches.

Using the list of boxes that need to be gift-wrapped, write a Python function that outputs the total number of square feet of wrapping paper that needs to be ordered.

https://courses.alrodrig.com/4932/boxes.txt

Solutions

Expert Solution

# Please refer to the attached screenshot of the code and the output in the solution belowL


f = open("boxes.txt", "r") # opens the file boxes.txt
fl =f.readlines() # reads the file line by line
totalWrap = 0 # amount of wrapping paper needed so far
for line in fl:
dimensions = line.split("x") # splits the line at "x" to obtain length, breadth and height of the cuboid
l = int(dimensions[0]) # Stores value of length
b = int(dimensions[1]) # Stores value of breadth
w = int(dimensions[2]) # Stores value of height
surfaceArea = 2*(l*b + b*w + w*l) # Stores value of total surface area of the cuboid
smallestsurfArea = min (l*b, b*w, w*l) # Stores value area of minimum surface area side
totalWrap += surfaceArea + smallestsurfArea # Accumulates the values to the total wrapping paper needed so far
print(totalWrap) # Prints the value of total wrapping paper that will be needed = Final Answer


Related Solutions

Firm X has a new promotional program that offers a free gift-wrapping service for its customers....
Firm X has a new promotional program that offers a free gift-wrapping service for its customers. Its customer-service department has practical capacity to wrap 5,000 gifts at a budgeted fixed cost of $4,950 each month. The budgeted variable cost to gift-wrap an item is $0.35. During September 2020, the department budgeted to wrap 4,500 gifts. Although the service is free to customers, a gift-wrapping service cost allocation is made to the department where the item was purchased. The customer-service department...
because of corona virus scare our local drug stores ran out of face masks but some...
because of corona virus scare our local drug stores ran out of face masks but some entrepreneurs have orderd these from china but are selling them at very high prices but our government has called this gouging and accuse these seller of taking an unfair advantage of an emergency the goverment has made these seller pay a fine and confiscated their inventions do you think this is good goverment policy to stop this trade ? why or why not?
The average take-out order size for Curry House restaurant is shown. Is average order size more...
The average take-out order size for Curry House restaurant is shown. Is average order size more on Saturday Night than Friday Night?                                                 α = 0.1 Friday Night Saturday Night Average Order Size $32.30 $37.60 Standard Deviation $3.3 $4.2 Number of Orders Sampled 17 15 Ho:_____________             Ha:_____________ Test Statistics: _______________________ Decision Rule: _______________________ Decision: _____________________ Interpretation: ___________________
A machine is out of order for minor work. Define controls exercised in maintenance. Department required...
A machine is out of order for minor work. Define controls exercised in maintenance. Department required for its maintenance.
A machine is out of order for major work. Define controls exercised in Maintenance Department required...
A machine is out of order for major work. Define controls exercised in Maintenance Department required for its Maintenance.
Kalamazoo Paper Company has three divisions: Recycling, Cardboard, and Paper. In order to determine the profit...
Kalamazoo Paper Company has three divisions: Recycling, Cardboard, and Paper. In order to determine the profit provided by each division, the company allocates all costs to the three divisions. As a result, for the year ended December 31, 2015, Kalamazoo reported a profit of $50,000 for Recycling, a profit of $60,000 for Paper, and a loss of $30,000 for Cardboard. If Cardboard has avoidable costs of $40,000 and unavoidable costs of $50,000 which of the following actions should be taken...
Can someone critique my paper please ? Excessive force has been defined as using more force...
Can someone critique my paper please ? Excessive force has been defined as using more force than required to gain compliance in an incident (Phillips, 2015). One of the most controversial incidents of deadly force by police officers involved an unarmed teenager named Michael Brown. Michael Brown was a black teenager from Ferguson, Missouri. The incident occurred on the 9th of August in 2014; a Ferguson police officer shot and killed the eighteen-year-old. The argument is that because Brown was...
In python Using the example code from the HangMan program in our textbook, create a Word...
In python Using the example code from the HangMan program in our textbook, create a Word Guessing Game of your choice. Design a guessing game of your own creation. Choose a theme and build your words around that theme. Keep it simple. Note: I would highly recommend closely reviewing the HangMan code and program from Chapter 10 before starting work on this project. You can run the program via my REPL (Links to an external site.). Using python Similar to...
The Lots More Store has a Janitorial Department and a Personnel Department that provide services to...
The Lots More Store has a Janitorial Department and a Personnel Department that provide services to three Sales Departments. The Janitorial Department cost is allocated based on space and the Personnel Department cost is allocated based on employees. The following information is available. Personnel Janitorial Sales Sales Sales Dept Dept #1 #2 #3 Budget $45 000 $30 000 Space (sq m) 4 000 1 000 30 000 20 000 50 000 No. of Employees 5 10 15 45 30 Using...
Our department has not processed legal or garnishment orders for a number of years. With the...
Our department has not processed legal or garnishment orders for a number of years. With the recent receipt of numerous orders, management has decided it would be beneficial to remind all payroll practitioners of our obligations under these orders. Please prepare a memo for our payroll department outlining our responsibilities and obligations under a legal or garnishment order.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT