Suppose $f : \mathbb{R}^{n} \rightarrow \mathbb{R}$ is continuous and $f(u) > 0$ if the point $u \in \mathbb{R}^{n}$ has at least one rational component. Prove that $f(u) \geq 0 $ for all $u \in \mathbb{R}^{n}$.
Partial Solution:
What remains to be proven is that $f(u) \geq 0$ for every $u \in \mathbb{R}^{n}$ with at all irrational components. Let $v$ be such a vector. Since every real number is the limit point of a rational sequence, we can define sequences $\{r_{1}\}, \{r_{2}\}, \ldots, \{r_{n}\},$ where $\{r_{k}\}$ converges to the $k^{\text{th}}$ component of $v$.
I don't really know how to finish from here. Can someone please help me?
For fixed $v \in \mathbb{R}^n$ write $v=(v^{(1)},\ldots,v^{(n)})$, i.e. $v^{(k)}$ is the $k$-th component of $v$ for $k \in \{1,\ldots,n\}$.
As you suggest, we choose for some some $k \in \{1,\ldots,n\}$ a rational sequence $(r_i)_{i \in \mathbb{N}}$ such that $r_i$ converges to $v^{(k)}$ as $i \to \infty$. Now define $$u_i := (v^{(1)},\ldots,v^{(k-1)},r_i, v^{(k+1)},\ldots,v^{(n)})$$ for $i \geq 1$. By construction, we have $f(u_i) \geq 0$ for all $i$ and $u_i \to v$ as $i \to \infty$.
Hint: Use the continuity of $f$ to conclude that $f(v) \geq 0$. (How can you express $f(v)$ in terms of $f(u_i)$?)