Expanding a function into a Fourier series with only sin.
\begin{equation*} f(x) = \begin{cases} 1 &\text{if } 0<x<\pi\\ 0 &\text{if } \pi/2<x<\pi \end{cases} \end{equation*}
I don't know how it calculates. The function's existed and it's not existed for $\pi/2 < x < \pi$, isn't it?
I've suspected the task's incorrect. So I tried to solve it changing first "if": \begin{equation*} f(x) = \begin{cases} 1 &\text{if } 0<x<\pi/2\\ 0 &\text{if } \pi/2<x<\pi \end{cases} \end{equation*} and I have $f(x) \sim 1 - 2\sum\limits_{n=1}^{\infty}\sin(2nx)/\pi n$.
Maybe I overlook something...
The Fourier series with period $P$ is given by $$f(x) \sim \frac {a_0}2 + \sum_{n=1}^\infty \left[a_n\cos\left(\frac{2\pi}Pnx\right) + b_n\sin\left(\frac{2\pi}Pnx\right)\right]$$ where $$a_n = \frac 2P\int_{p_0}^{p_0 + P}\cos\left(\frac{2\pi}Pnx\right)\,dx, \quad n \ge 0\\b_n = \frac 2P\int_{p_0}^{p_0 + P}\sin\left(\frac{2\pi}Pnx\right)\,dx, \quad n > 0$$ and $p_0$ is the beginning of a period. If $f$ is periodic with period $P$, then it does not matter what $p_0$ is, the integrals for the coefficients will always give the same results.
An important detail not miss is this: while $a_n$ and $b_n$ for $n \ge 1$ are used straight in the Fourier series, $a_0$ is divided by $2$. In your series, you apparently missed that. The constant term of a Fourier series has to be at the height where the graph of $y=f(x)$ is equally balanced above and below it, as both cosine and sine are balanced in their areas above and below the $x$-axis. For your function, this is at $\frac 12$, not $1$.
Now your $f$ is defined on $(0,\pi)$, so the naive thing to do is to take $P = \pi$, which gives $$a_0 = \frac 2\pi\int_0^\pi f(x)\,dx = \frac 2\pi\left(\int_0^{\pi/2}dx + \int_{\pi/2}^\pi 0\, dx\right) = 1$$ Since the second half of the period is $0$, I'll just leave it off from the start from here on: $$a_n = \frac 2\pi\int_0^{\pi/2}\cos(2nx)\,dx = \frac 2\pi\left[\frac{\sin 2nx}{2n}\right]_0^{\pi/2} = \frac 1{\pi n}(0 - 0) = 0$$ So there are no cosine terms as desired. And $$b_n = \frac 2\pi\int_0^{\pi/2}\sin(2nx)\,dx = \frac 2\pi\left[\frac{-\cos 2nx}{2n}\right]_0^{\pi/2} = \frac 1{\pi n}(-\cos n\pi + 1)\\b_n = \begin{cases}\dfrac 2{\pi n}&n\text{ odd}\\[.5em]0&n\text{ even}\end{cases}$$
So, $$f(x) \sim \frac 12 + \frac 2\pi\sum_{n=0}\dfrac{\sin (4n+2)x}{2n+1}$$
There are some alternative approaches. For example, we could extend $f$ to $(-\pi, 0)$ by $f(x) = -f(-x), x \in (-\pi,0)$. This makes $f$ an odd function on an interval from $-\pi$ to $\pi$. Because the problem is only about what happens in $(0,\pi)$, the fact it behaves differently on $(-\pi, 0)$ does not matter. Now we can use a period of $2\pi$, and all of the $a_n$, including the constant term, are $0$ because $f$ is odd. The $b_n$ are given by $$b_n = \frac 1\pi\left[\int_{-\pi/2}^0-\sin nx\,dx + \int_0^{\pi/2}\sin nx\,dx\right] = \frac 2\pi\int_0^{\pi/2}\sin nx\,dx$$ Working it out gives $$f(x) \sim \sum_{n=0}^\infty \frac {(-1)^n}{2n+1} \sin \,(2n+1)x$$