Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions 8-10 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 i r) as output argument.

Questions 8-10 image text in transcribed
image text in transcribed
5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 i r) as output argument. Paste the function code below. def SphereArea (r): return (4*22*r*r)/7 print (SphereArea (5)) 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. SA-Sphere Area(2) 7. Design an algorithm in pseudocode for a program (script file) that will prompt a user for the radius value, call each of the functions, and then output the values of surface area, volume, and surface-to-volume ratio (all formatted to 2 decimal places). # Function to calculate Volume of Sphere def volume(r): vol = (4/3) * math.pirerer return vol # Function To Calculate Surface Area of Sphere def surfasearea(r): surar - 4 math.plorer return sur ar # Function to calculate surface to volume ratio def surfacetovolume(r): return surfacearea(r)/volume(r) # Driver Code # Taking input radius = float(input("Enter radius:")) # Print upto 2 decimal places print("Volume Of Sphere: {:.2f}".format(volume(radius))) print("Surface Area Of Sphere : {:.2f}".format(surfacearea(radius))) print("Surface Area to Volume ratio : {:.2f}".format( surfacetovolume(radius))) 8. Program your algorithm, and paste the code for the main program below. Your program must contain the lines of code indicated below, exactly as written: Paste code here SYAL - Spherevol(SRadius); Saree - SphereArea (SRadius); SVBaphers - Sarso / SVALI $(add some relevant comment) (add some relevant comment) (add some relevant comment) 9. Test the program. Paste output for radius values of 4 and 0 (what happens here? Why?). 10. Modify your functions so that they will accept vector input for the radius. Validate your functions from the command line by setting the variable SRadius - 0 : 2 and then calling each function using SRadius. (Verify that the results are correct for each.) Paste here the portion of your code that was changed, and evidence that your functions work properly

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago