Python

“””This basic Python function calculates the surface
area of cylinders both solid and hollow.”””
def cyclinder_surface_area(radius, height, has_top_and_bottom):
side_area = 2* 3.14 * height * radius
if has_top_and_bottom:
top_area = 3.14 * radius**2
surface_area = side_area + 2 * top_area
return surface_area
else:
return side_area

test1 = cyclinder_surface_area(2, 2, True)
test2 = cyclinder_surface_area(2, 2, False)
test1, test2

Published by Eraj

Think lightly of yourself and deeply of the world.

Leave a comment