80.8k views
5 votes
Write a function my_clynder (r,h), where r and h are the radius and height of a cylinder, respectively, and the output is a list [s, v] where s and v are the surface area and volume of the same cylinder, respectively. Recall that the surface area of a cylinder is 2πr2 + 2πrh, and the volume is πr2h. Assume that r and h are float.

1 Answer

3 votes

Final answer:

To write the my_cylinder function, we can use the given formulas for the surface area and volume of a cylinder. We can plug in the values of r and h into these formulas to calculate the surface area and volume of the cylinder. The function should then return a list [S, V] where S is the surface area and V is the volume.

Step-by-step explanation:

To write the my_cylinder function, we can use the given formulas for the surface area and volume of a cylinder

  1. Surface Area: S = 2πrh + 2πr2
  2. Volume: V = πr2h

We can plug in the values of r and h into these formulas to calculate the surface area and volume of the cylinder. The function should then return a list [S, V] where S is the surface area and V is the volume. Here's an example implementation in Python:

import math
def my_cylinder(r, h):
S = 2 * math.pi * r * h + 2 * math.pi * r**2
V = math.pi * r**2 * h
return [S, V]

User Sean Lin
by
8.4k points