Consider the following two statements
If $X$ is a continuous random variable and $Y=g(X)$ is a function of $X$, then $Y$ itself is a random variable.
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?
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.