Solution:
We know that the attenuation in optical fiber is,
$
A=\left(\frac{10}{L}\right) \log \frac{P_i}{P_f} \mathrm{~dB} / \mathrm{km}\\
$
where $P_f$ is the input power and $P_f$ is the power remaining after length $L \mathrm{~km}$ has been traversed.
or, the power loss in fiber can be written as $A=10 \log \left(\frac{P_i}{P_f}\right) \mathrm{dB}$
In present case, $P_f=\frac{1}{2} P_i \quad \therefore A=10 \log 2 \approx 3 \mathrm{~dB}$
So the loss is $3 \mathrm{~dB}$ when the output is half that of input power. In second part given $A=30 \mathrm{~dB} / \mathrm{km}$
Let us consider length of fibre $1 \mathrm{~km}$, then