Function of a random variable is a random variable Consider the following two statements
Statement 1

If $X$ is a continuous random variable and $Y=g(X)$ is a function of
$X$, then $Y$ itself is a random variable.

Statement 2

A random variable is a function from a sample space S into the real
numbers.

From statement 2 it is clear that a random variable should be a real valued function.
Then how can any function of a random variable can be another random variable as per statement 1? Where my interpretation is going wrong?
 A: Statement 1 is wrong. If $X$ is a random variable and $g:\mathbb R \to \mathbb R$ is a measurable function then $g(X)$ is a random variable. However, if $X$ is a discrete random variable then any function of $X$ is a random variable.
A: Without any more context, statement 1 is completely wrong. Let gives context. Statement 2 doesn't really have sense as well. I denote $\mathcal B(\mathbb R)$ the Borel set of $\mathbb R$


*

*Let $(\Omega ,\mathcal F,\mathbb P)$ a probability space and let $X:\Omega \to \mathbb R$ is a random variable if $X^{-1}(B)\in \mathcal F$ for all $B\in \mathcal B(\mathbb R)$.

*Let $g:\mathbb R\to \mathbb R$ a Borel function (i.e. $g^{-1}(B)\in \mathcal B(\mathbb R)$ for all $B\in\mathcal B(\mathbb R)$). Then $g(X)$ is indeed a r.v. since $$(g\circ X)^{-1}(B)=X^{-1}\left(\underbrace{g^{-1}(B)}_{\in \mathcal B(\mathbb R)}\right)\in \mathcal B(\mathbb R),$$
which is completely independent of continuity of $X$ that have no sense in context of probability (there is no topology on $(\Omega ,\mathcal F,\mathbb P)$. May by by $X$ continuous you mean the density function is continuous, but still, no need this property to have $g(X)$ a r.v. 
A: $X : \Omega \to \mathbb{R}$, i.e. to each $\omega$ you pair some real number $X(\omega)$.
Then, $Y$ given by $g(X)$ should be interpreted as pairing $g(X(\omega))$ to each $\omega$.
In other words $Y : \Omega \to \mathbb{R}$ and is just $g \circ X$.
