Prove $Q(x):=\frac{f}{g}(x)$ is measurable 
If $(X, \mathcal{B})$ is a measurable space and $f, g: X\to \mathbb{R}$ are two measureable functions. Define:
  $$Q(x):=\frac{f}{g}(x) = \begin{cases} f(x)/g(x)  &  \text{if }  
     g(x)\neq 0 \\
      0  &  \text{if } g(x)= 0 \end{cases} $$
  Prove $Q$ is measurable.

If I consider the $0\in \mathbb{R}$, then how to prove $Q^{-1}(0)$ is measurable? How about this idea?
$$\{x\in E: Q(x)\leq a\}=\cup_{r\in \mathbb{Q}}\bigg(\{x\in E\setminus\{0\}: f(x)\leq r\}\cup\{x\in E\setminus\{0\}: g(x)\geq r/a\}\bigg)\cup \{x\in \{0\}: g(x)=0\}$$
 A: Let us make life easier by first showing that the function $\frac 1g(x) = 1_{\{g(x)  \neq 0\}}\frac 1{g(x)}$  is measurable(where $1_{x \neq 0}$ is the indicator function of $x \neq 0$). Recognize that $\frac fg(x) = f(x) \frac 1g(x)$ is the pointwise product, so we can deal with this separately.
(Notation : Stuff like $\{g \leq y\}$ means $\{x \in E : g(x) \leq y\}$ and similarly for the others. Get used to it, it is very common notation).
Indeed, for any $y < 0$, we have $\{\frac 1g  \leq y\} = \{0 > g \geq \frac 1y\}$. We have $\{\frac 1g \leq 0\} = \{g \leq 0\}$ and for $y > 0$, we have $\{\frac 1g \leq y\} = \{g \leq 0\} \cup \{g \geq \frac 1y\}$. Since all the sets on the RHS of each of these equalities are measurable, we conclude that $\frac 1g$ is measurable.

Now, we can conclude with showing the product of two measurable functions is measurable. Indeed, let $f,h$ be two measurable functions. Then, take any $y \in \mathbb R$. We need to look at signs of expressions very carefully, so we take all unions over positive rationals.
$y < 0$ : We have $$
\{fh \leq y\} = \left[\cup_{r \in \mathbb Q^+} \{0 < f \leq r\} \cap \left\{h \leq \frac yr\right\} \right]
\\ \bigcup \\
\left[\cup_{r \in \mathbb Q^+} \{f \leq -r\} \cap \left\{h \geq \frac {-y}r\right\}\right]
$$
Of course, $\{fh = 0\} = \{f = 0\} \cup \{h = 0\}$. Now, do something similar for $\{fh \leq y\}$ where $y > 0$ (I want to see your attempt) and finish the argument.
