Step 1:
Given $dy=\cos x(2-y \;cosec x)dx$
This can be written as
$\large\frac{dy}{dx}$$=2\cos x-y \cos x. cosec x$
$=2 \cos x -y . \large\frac{\cos x}{\sin x}$
$=2 \cos x- y \cot x$
Therefore $\large\frac{dy}{dx}$$+y \cot x= 2\cos x$
Clearly this is a linear differential equation of the form
$\large\frac{dy}{dx}$$+Py=Q$
Where $P=\cot x$ and $Q=2 \cos x$
Let us find the integral factor I.F which is
$e^{\large\int pdx}=e^{\large\int \cot xdx}$
But $\int \cot x dx=\log |\sin x|$
Therefore $ I.F=e^{\large\log |\sin x|}$
But $e^{\large\log x}=x$
$e^{\large\log(\sin x)}=\sin x$
Hence the required solution is
$y \times I.F=\int Q \times I.F dx+c$
$y \sin x=\int 2 \cos x.\sin x dx+c$
But $2 sin x\cos x=\sin 2x$
Therefore $ y \sin x =\int \sin 2x+c$
$ \int \sin 2x=\large\frac{-1}{2}$$\cos 2x$
Hence $ y \sin x=\large\frac{-1}{2}$$\cos 2x+c$
$2y\sin x+\cos 2x=c$
Step 2:
Given $y=2$ when $x=\pi/2$
Substituting this to find the value of c
$2(2)\sin \pi/2+\cos 2.\pi/2=c$
But $\sin \pi/2=1$ and $\cos \pi=-1$
=>$4 \times 1+(-1)=c$
=>$4 -1=c=>c=3$
Hence the required solution is
$2y \sin x+\cos 2x=3$
or $2y \sin x+\cos 2x-3=0$