Given:
Image distance, v = 12 cm (Image is erect.)
Height of the object, h = 0.5 cm
Height of the image, h' = 2.0 cm
Applying magnification formula, we get:
m = v/u = h'/h
12/u = 2.0/0.5
or, object distance, u = 3 cm
Applying lens formula, we get:
1/v 1/u = 1/f
1/(12) 1/(-3) = 1/f
or, 1/f = 3/12
or, focal length, f = 4.0 cm