Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Tape Length Calculation

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Tape Length Calculation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Imperial College London facilities may need to estimate how much tape remains on a roll. Given the roll's outer radius, empty-core radius, tape width, and tape thickness, calculate the tape length.

Treat the wound tape as the annular region between the core and the outer surface. Use volume conservation: the volume of the wound tape equals the volume of a rectangular strip with length L, width w, and thickness t.

Formal Specification

Implement tape_length(outer_radius, core_radius, width, thickness). All dimensions are positive real numbers in the same unit. Return the tape length in that unit as a floating-point number. The tape is wound tightly, with no gaps or compression.

The roll volume is:

π * (outer_radius² - core_radius²) * width

The tape volume is:

length * width * thickness

Therefore, calculate the length without iterating through individual layers. The supplied width must be accepted even though it cancels algebraically.

Constraints

  • 0 < core_radius <= outer_radius <= 10^6
  • 0 < width <= 10^4
  • 0 < thickness <= 10^3
  • All dimensions use consistent units
  • The answer must be accurate to at least 1e-6 relative or absolute error

Function Signature

def tape_length(outer_radius, core_radius, width, thickness):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output