Is there a simple function $f(x)$ that follows $2$ rules when $x$ is rational?
$x$'s simplest form is $\frac{a}{b}$ if $x$ is a rational number.
$$f(x) \in \begin{cases} \mathbb{R} \setminus \mathbb{Q}, \ \ \ \ x=\frac{a}{b} \text{ and } a + b = \text{even} \\ \mathbb{Q}, \ \ \ \ \ \ \ \ \ \ \ x \not\in \mathbb{Q} \text{ and } a + b = \text{odd} \end{cases}$$
for $x$ being irrational it doesn't need to follow any specific rule besides being continuous.
and for $x=0$ the simple fraction is $\frac{0}{1}$ so $f(0)$ is rational