Is $f$ measurable? $f(x)=\begin{cases} 0& x\in \mathbb{R}-\mathbb{Q} \\ \frac{1}{b} & x\in \mathbb{Q},x=\frac{a}{b},\text{gcd}(a,b)=1 \end{cases}$ Let $f:\mathbb{R}\to\mathbb{R}$
Is $f$ measurable? $f(x)=\begin{cases} 0& x\in \mathbb{R}-\mathbb{Q} \\
 \frac{1}{b} & x\in \mathbb{Q},x=\frac{a}{b},\text{gcd}(a,b)=1,b>0 \end{cases}$

To this function can I use the same answer of $f(x)=\begin{cases} 0, x\in I \cap [0,1] \\ \frac{1}{q} , x=\frac{p}{q}, p,q \in \mathbb{N}, (p,q)=1\end{cases}$ Is $f$ measurable? Continuous?
In that case $f(x)=0$ if $x \in I\cap[0,1]  $
Any hint please

Assuming the measure is lebesgue measure, We have that $\mathbb Q$ is a set of measure $0$. And hence $f=0$ almost everywhere, and hence it is measurable because the constant function $0$ is so.
A rigorous proof would follow as:
Let $A\subset \mathbb R$, be measurable.
Case 1: $0 \in A$
Then $f^{-1}(A)=(\mathbb R-\mathbb Q)\cup B$, where $B\subset \mathbb Q$. (Note: $B$ may be empty). Since we are working in lebesgue measure ,which is complete and $\mathbb Q$ is a set of measure $0$, so $B$ is measurable.
And hence we have $f^{-1}(A)=(\mathbb R-\mathbb Q)\cup B$, union of two measurable set is measurable.
Case 2:$0\notin A$
Then $f^{-1}(A)\subset \mathbb Q$, and by the same reason as above(proof for $B$), $f^{-1}(A)$ is measurable.
Hence for $A\subset \mathbb R$ measurable,$f^{-1}(A)$ is measurable.Proving $f$ is measurable.
