Does there exist an onto map from $[0,1]$ to $\mathbb Q$? Does there exist an onto map from $[0,1]$ to $\mathbb Q$?
I am unable to come up with a proof or a counter example.
If we take $f$ to be an onto mapping $[0,1]$ to $Q$, then $f([0,1])=\mathbb Q$.
I am unsure if it will give any contradiction. If not then what will be the map?
Can someone please help me out?
 A: If by "map" you mean a "function" then yes. First take any surjection $g:[0,1]\to\mathbb{R}$, e.g. variant of $g(x)=\tan(x)$. Now pick any $x_0\in\mathbb{Q}$ and define
$$f:\mathbb{R}\to\mathbb{Q}$$
$$f(x)=\begin{cases}
x &\text{if }x\in\mathbb{Q} \\
x_0 &\text{otherwise}
\end{cases}$$
It is surjective which I leave as an exercise. You can then compose that $f$ with  $g$ to obtain surjection $[0,1]\to\mathbb{Q}$.
If, on the other hand, by "map" you mean "continuous function" then the answer is "no": $\mathbb{Q}$ is (totally) disconnected while $[0,1]$ is connected.
A: $$ \Large{(0,1)\xrightarrow{f_1(x)\ =\ \tan\left(\pi x-\frac{\pi}{2}\right)} \mathbb{R} \xrightarrow{f_2(x)\ =\ x\ \text{ if }\ x\in\mathbb{Q},\ -\frac{4}{5}\ \text{ otherwise} } \mathbb{Q}}$$
Dealing with $0$ and $1$ in the domain is simple: just map $0$ to $\frac{3}{2}$ and map $1$ to $\frac{5}{3}.$
A: What's a function that (when restricted to some interval) has range $\Bbb{R}$?  Let's translate the input interval and only use its values when they're rational and the translated function is defined.
$$  f(x) = \begin{cases}
\tan\left( \pi x - \frac{\pi}{2}  \right)  ,&  x \in (0,1), \tan\left( \pi x - \frac{\pi}{2}  \right) \in \Bbb{Q}  \\
0  ,& \text{otherwise}
\end{cases}  $$
A: Yes:
Do an enumeration $E_1$ of the Rationals in $[0,1] \cap \mathbb Q$ and an enumeration $E_2$ of the "Stand alone" $ \mathbb Q$. Then map $E_1(j) \rightarrow E_2(j); j=1,2,..$
and map all Irrationals to a constant Rational, such as $1/2$.
A: Note that to show that the positive rationals are countable, we can use the mapping $$\frac{p}{q} \mapsto 2^p3^q$$ which is onto. It is easy to see then that
$$f(x)=\begin{cases}
\frac{p}{q} &\text{if }x=\frac{1}{2^p3^q}&\text{with }p,q &\text{integers}\gt0\\-
\frac{p}{q} &\text{if }x=\frac{1}{2^p3^q\sqrt{2}}&\text{with }p,q &\text{integers}\gt0\\
0 &\text{otherwise}
\end{cases}$$
is onto from $[0,1]$ to the rationals.
