for which values of $x,y$ is $[x,y]\cap \mathbb{Q}$ closed? for which values of $x,y$ is $[x,y]\cap \mathbb{Q}$ closed in the metric space $(\mathbb{Q},d)$ where $d(x,y) = |x-y|$
my attempt: 
I suspected it's closed for all real numbers:
let $x,y \in \mathbb{Q}$ then if $[x,y]\cap \mathbb{Q}$ is closed it means the compliment is open i.e. $(-\infty,x) \cup (y,\infty)$ is open. The set $(-\infty,x) \cup (y,\infty)$ is obviously open as between any two rational numbers there is another rational number so I can find a ball with radius $r>0$ in the set. (Is this logic correct?)
if $x,y$ are irrational however I don't know how to proceed - will the complement on the set still be $(-\infty,x) \cup (y,\infty)$? and if so how do I argue it is open (or if it isn't)
 A: Recall the following theorem.
Theorem. Let $X$ be a subspace of a topological space $Y$ and let $E\subset X$. Then $E$ is closed in $X$ if there exists a set $W$ closed in $Y$ such that $E=X\cap W$.
The proof of this theorem is not difficult and worth writing down yourself and good practice for thinking about subspaces. 
If you accept this theorem, your problem becomes easier.
In your problem, we have
\begin{align*}
Y &= \Bbb R & X &=\Bbb Q & E &= [x,y]\cap\Bbb Q
\end{align*}
So your question translates to: Does there exist a set $W$ closed in $\Bbb R$ such that $E=W\cap\Bbb Q$?
The answer is quite obvious when phrased this way. Do you see how to find $W$?
A: In all cases the complement will be 
$$\Bbb Q\cap\Big((\leftarrow,x)\cup(y,\to)\Big)$$
(note that you really should include the intersection with $\Bbb Q$, unless you’ve previously established a convention that your interval notation is to be understood to mean intervals in $\Bbb Q$ rather than in $\Bbb R$), and your argument for this being open works equally well for all $x$ and $y$, not just the rational ones. All you need is the fact that between any two real numbers there is a rational.
