@@ -134,7 +134,31 @@ def surface_area_cone(radius: float, height: float) -> float:
134134 raise ValueError ("surface_area_cone() only accepts non-negative values" )
135135 return pi * radius * (radius + (height ** 2 + radius ** 2 ) ** 0.5 )
136136
137+ def lateral_surface_cone (radius : float , height : float ) -> float :
138+ """
139+ Calculate the Lateral Surface Area of a Cone.
140+ Wikipedia reference: https://en.wikipedia.org/wiki/Cone
141+ Formula: pi * r * (h ** 2 + r ** 2) ** 0.5
137142
143+ >>> lateral_surface_cone(10, 20)
144+ 702.4814731040726
145+ >>> lateral_surface_cone(6, 8)
146+ 188.49555921538757
147+ >>> lateral_surface_cone(0, 0)
148+ 0.0
149+ >>> lateral_surface_cone(1, -2)
150+ Traceback (most recent call last):
151+ ...
152+ ValueError: lateral_surface_cone() only accepts non-negative values
153+ >>> lateral_surface_cone(-1, 2)
154+ Traceback (most recent call last):
155+ ...
156+ ValueError: lateral_surface_cone() only accepts non-negative values
157+ """
158+ if radius < 0 or height < 0 :
159+ raise ValueError ("lateral_surface_cone() only accepts non-negative values" )
160+ return pi * radius * (height ** 2 + radius ** 2 ) ** 0.5
161+
138162def surface_area_conical_frustum (
139163 radius_1 : float , radius_2 : float , height : float
140164) -> float :
@@ -201,6 +225,30 @@ def surface_area_cylinder(radius: float, height: float) -> float:
201225 raise ValueError ("surface_area_cylinder() only accepts non-negative values" )
202226 return 2 * pi * radius * (height + radius )
203227
228+ def lateral_surface_cylinder (radius : float , height : float ) -> float :
229+ """
230+ Calculate the Lateral Surface Area of a Cylinder.
231+ Wikipedia reference: https://en.wikipedia.org/wiki/Cylinder
232+ Formula: 2 * pi * r * h
233+
234+ >>> lateral_surface_cylinder(10, 20)
235+ 702.4814731040726
236+ >>> lateral_surface_cylinder(6, 8)
237+ 301.59289474462014
238+ >>> lateral_surface_cylinder(0, 0)
239+ 0.0
240+ >>> lateral_surface_cylinder(1, -2)
241+ Traceback (most recent call last):
242+ ...
243+ ValueError: lateral_surface_cylinder() only accepts non-negative values
244+ >>> lateral_surface_cylinder(-1, 2)
245+ Traceback (most recent call last):
246+ ...
247+ ValueError: lateral_surface_cylinder() only accepts non-negative values
248+ """
249+ if radius < 0 or height < 0 :
250+ raise ValueError ("lateral_surface_cylinder() only accepts non-negative values" )
251+ return 2 * pi * radius * height
204252
205253def surface_area_torus (torus_radius : float , tube_radius : float ) -> float :
206254 """Calculate the Area of a Torus.
@@ -576,9 +624,12 @@ def area_reg_polygon(sides: int, length: float) -> float:
576624 print (f"Sphere: { surface_area_sphere (20 ) = } " )
577625 print (f"Hemisphere: { surface_area_hemisphere (20 ) = } " )
578626 print (f"Cone: { surface_area_cone (10 , 20 ) = } " )
627+ print (f"Cone, lateral: { lateral_surface_cone (10 , 20 ) = } " )
579628 print (f"Conical Frustum: { surface_area_conical_frustum (10 , 20 , 30 ) = } " )
580629 print (f"Cylinder: { surface_area_cylinder (10 , 20 ) = } " )
630+ print (f"Cylinder, lateral: { lateral_surface_cylinder (10 , 20 ) = } " )
581631 print (f"Torus: { surface_area_torus (20 , 10 ) = } " )
582632 print (f"Equilateral Triangle: { area_reg_polygon (3 , 10 ) = } " )
583633 print (f"Square: { area_reg_polygon (4 , 10 ) = } " )
584634 print (f"Reqular Pentagon: { area_reg_polygon (5 , 10 ) = } " )
635+
0 commit comments