← Back to challenges

Make a Vessel of Height

PythonHardalgorithmslogicmathnumbersgeometry

Instructions

A company asks a small-scale manufacturer to produce packaging in which they can ship their cooking oil. The company also gives the design for how the vessel should look (the shaded portion filled in the image below). Depending upon the volume of oil to be packaged, the company requires vessels of varying height.

Create a function to determine what the height of the vessel should be, depending on the given volume of oil. Return height of the vessel in centimeters, with up to two decimals of precision.

Cone in Cylinder

Examples

height_needed(0.5) ➞ 19.1

height_needed(5) ➞ 190.99

height_needed(10) ➞ 381.97

Notes

  • Assume the radius (5cm) will stay constant for all different volume vessels.
  • volume will be given in the unit of litre.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.