Problem: Let $(X,d)$ be a metric space with a countable dense subset $D$. Then every open subset $U$ is the union of balls with centers in $D$ and rational radius.
My attempt:
Let $U$ be non empty and open in $X$. So, for $x\in U$, there exists rational $r_x>0$ such that $B(x,r_x)\subseteq U$. Since $\overline{D}=X$, there exists $x'\in D\cap B(x,\frac{r_x}{2})$. Note, $x\in B(x',\frac{r_x}{2})$ and further, by the triangle inequality, $x\in B(x',\frac{r_x}{2})\subseteq B(x,r_x)\subseteq U$. Hence $U$ is the union of all such balls.
Is my attempt correct?
Yes, this is fine. Nitpick: start with a real $r_x>0$ (which is the definition) and then find $q_x \in \Bbb Q$ such that $0 < q_x < \frac{r_x}{2}$ (here you're using an essential property of $\Bbb Q$, namely that it is dense in $\Bbb R$; mention that too) and show $B(x',q_x) \subseteq B(x,r_x)$ again by the triangle inequality. At this level, you should mention all details and all facts you're relying on, IMHO.