Program for focal length of a lens | Function to determine the focal length of a lens ; Variable to store the distance between the lens and the image ; Variable to store the distance between the lens and the object
def focal_length ( image_distance , object_distance ) NEW_LINE INDENT : return 1 / ( ( 1 / image_distance ) + ( 1 / object_distance ) ) NEW_LINE DEDENT image_distance = 2 NEW_LINE object_distance = 50 NEW_LINE result = focal_length ( image_distance , object_distance ) NEW_LINE print ( " Focal ▁ length ▁ of ▁ a ▁ lens ▁ is ▁ " , result , " ▁ units . " ) NEW_LINE