$\int_{\frac{\pi}{2}}^{\pi} e^{x}\left(\frac{1-\sin x}{1-\cos x}\right) d x$
$I=\int_{\frac{\pi}{2}}^{\pi} e^{x}\left(\frac{1-\sin x}{1-\cos x}\right) d x$
$=\int_{\frac{\pi}{2}}^{\pi} e^{x}\left(\frac{1-2 \sin \frac{x}{2} \cos \frac{x}{2}}{2 \sin ^{2} \frac{x}{2}}\right) d x$
$=\int_{\frac{\pi}{2}}^{\pi} e^{x}\left(\frac{\operatorname{cosec}^{2} \frac{x}{2}}{2}-\cot \frac{x}{2}\right) d x$
Let $f(x)=-\cot \frac{x}{2}$
$\Rightarrow f^{\prime}(x)=-\left(-\frac{1}{2} \operatorname{cosec}^{2} \frac{x}{2}\right)=\frac{1}{2} \operatorname{cosec}^{2} \frac{x}{2}$
$\therefore I=\int_{\frac{\pi}{2}}^{\pi} e^{x}\left(f(x)+f^{\prime}(x)\right] d x$
$=\left[e^{x} \cdot f(x) d x\right]_{\frac{\pi}{2}}^{\pi}$
$=-\left[e^{x} \cdot \cot \frac{x}{2}\right]_{\frac{\pi}{2}}^{\pi}$
$=-\left[e^{x} \times \cot \frac{\pi}{2}-e^{\frac{\pi}{2}} \times \cot \frac{\pi}{4}\right]$
$=-\left[e^{\pi} \times 0-e^{\frac{\pi}{2}} \times 1\right]$
$=e^{\frac{\pi}{2}}$