Program to find slant height of cone and pyramid | Python 3 program for the above approach ; Function to calculate slant height of a cone ; Store the slant height of cone ; Print the result ; Function to find the slant height of a pyramid ; Store the slant height of pyramid ; Print the result ; Driver Code ; Dimensions of Cone ; Function Call for slant height of Cone ; Dimensions of Pyramid ; Function to calculate slant height of a pyramid
from math import sqrt , pow NEW_LINE def coneSlantHeight ( cone_h , cone_r ) : NEW_LINE INDENT slant_height_cone = sqrt ( pow ( cone_h , 2 ) + pow ( cone_r , 2 ) ) NEW_LINE print ( " Slant ▁ height ▁ of ▁ cone ▁ is : " , slant_height_cone ) NEW_LINE DEDENT def pyramidSlantHeight ( pyramid_h , pyramid_s ) : NEW_LINE INDENT slant_height_pyramid = sqrt ( pow ( pyramid_s / 2 , 2 ) + pow ( pyramid_h , 2 ) ) NEW_LINE print ( " Slant ▁ height ▁ of ▁ pyramid ▁ is : " , " { : . 5f } " . format ( slant_height_pyramid ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT H1 = 4.5 NEW_LINE R = 6 NEW_LINE coneSlantHeight ( H1 , R ) ; NEW_LINE H2 = 4 NEW_LINE S = 4.8 NEW_LINE pyramidSlantHeight ( H2 , S ) NEW_LINE DEDENT