Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python VW PT Jl Ft III: Picking up the pieces (25 points) Write a function capsu Tunction capsule volume that computes the volume of material

python
image text in transcribed
VW PT Jl Ft III: Picking up the pieces (25 points) Write a function capsu Tunction capsule volume that computes the volume of material required to create a roundo metal capsule with walls of a provided thickness. The function takes three arguments that prom rate a rounded, cylin- that provide the dimensions of the capsules 1. length: the length of the capsule in cm 2. radius: the radius of the capsule in cm 3. thickness: the thickness of the capsule's walls in cm length h Cr-thimedes 3 ther-thinkwas) Clatha acts-tharknes? + TV (2 thinkes) n (length 32) thickness 400 with 21state) thickness = t-t. > radius Tz = thickness tt. & T = To thuhness Note that each end of the capsuje is hemispherical The radius of each hemisphere is the same as the radius of the cylindrical part of the capsule As shown in the figure above, the cavity inside the capsule is also cylindrical with hemispherical ends The thickness of the wall determines the radius of the cavity (Hint: can you derive a formula to get the radius of the cavity?) each end of the caps/As shown in the Ligamines the radius of the You will find the following formulas helpful: Volume of a sphere of radius : Volume of a cylinder of radius r and height h: rh In your code, you must use math.pi to perform the computations, or else it is likely your code will generate incorrect results. Your code must also do some basic error-checking. Specifically, if the length of the capsule is less than or equal to two times the radius, return the tioating-point value -1.0 to indicate invalid parameters. Or, if any of the three arguments is 0 or negative, return -1.0. Examples: CSE 101 - Spring 2020 Homework #1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions