If $X$ has genus $=1,2$, then it has a degree 2 holomorphic map $X\to \mathbb P^1$ Let $X$ be a compact Riemann surface of genus $1$ or $2$.

Show that $X$ admits a holomorphic function $f: X \to \mathbb P^1$ of degree $2$.

I think it's an application of Riemann Roch's theorem, but I'm not sure.
 A: As you correctly say, we should use Riemann-Roch. In general, constructing a map $f:X\to \Bbb{P}^1$ involves constructing a global meromorphic function, which is controlled by examining $H^0(X,\mathcal{L}(D))$ for $D$ a divisor. We do this using Riemann-Roch, by setting $\ell(D)=\dim_{\Bbb{C}} H^0(X,\mathcal{L}(D))$ and writing:
$$ \ell(D)-\ell(K-D)=\deg D+1-g.$$
Finding Meromorphic Functions:
To get degree $2$ maps $f:X\to \Bbb{P}^1$, we want to find degree $2$ divisors with nonconstant global sections. That is, we need $\ell(D)\ge 2$. For $g=1$, let $D=2P$ for $P$ some point of $X$. Then
$$ \ell(2P)-\ell(K-2P)=2+1-1=2.$$
Now, $\deg K=2g-2=0$, so $\deg(K-2p)=-2$, and hence $\ell(K-2P)=0.$ Therefore, Riemann-Roch reads $\ell(2P)=2$ and hence we find a nonconstant global meromorphic function, which gives a map to $\Bbb{P}^1$.
In the case of $g=2$, we have $\deg (K-2P)=2g-2-2=0.$ So, $\ell(K-2P)=1$. Thus, Riemann-Roch reads
$$ \ell(D)-\ell(K-2P)=2+1-2=1$$
and hence $\ell(D)=2$. The same argument produces a global meromorphic function as we want.
Degree Calculations: to see that indeed the degree of the map in the $g=1$ case is degree $2$, you can use Riemann-Roch to see that $\ell(P)=1$, hence contains only constant functions. So, the global section coming from $2P$ must have a pole of order $2$ at $P$. Hence, $f:X\to \Bbb{P}^1$ has $f^*(\infty)=2P$. Then, we see that $\deg(f^*D)=\deg f\cdot \deg D$ and here $D=\infty$. so that $\deg f=2$.
The $g=2$ case is slightly more involved. Because $\deg(K-P)=1$, we can't guarantee that $\ell(K-P)=0$. If $\ell(K-P)=0$, then by Riemann-Roch
$$ \ell(P)=1+1-2=0$$
and so we see that $\ell(2P)$ consists of multiples of a function vanishing to order $2$ and $P$ and we are done again by the argument as with $g=1$. In the case where $\ell(K-P)\ne 0$, we say that the divisor $K-P$ is special. Clifford's Theorem gives a bound in this case by
$$ \ell(K-P)-1\le \frac{\deg (K-P)}{2}=\frac{1}{2}.$$
So, $\ell(K-P)=1$. Then, by Riemann-Roch
$$ \ell(P)-\ell(K-P)=0$$
so that $\ell(P)=\ell(K-P)=1$ and so our global meromorphic function must vanish to order $2$ at $P$. Hence, $f^*(\infty)=2P$ and $\deg f=2$.
