Is expectation a function? I think the expectation is a function of random variables. I also know that a function of a random variable is a random variable. So the expectation is a random variable? But I also know the expectation is a constant. I am confused about this.
 A: Expectation is not "function" of a random variable.  A function f(X) of the r.v. X depends only on the single realization of X, whereas E[X] depends on the entire distribution.  
A conditional expectation, however, such as E[X|Y] can be thought of as a function of Y, and is a random variable.
A: The expectation of a random variable denoted $E:\mathbb{X}^n\rightarrow\mathbb{R^n}$ where $\mathbb{X}^n$ is a vector space of random vectors $X \in \mathbb{X}^n$ over the field $\mathbb{R^n}$ is a functional mapping from a vector space onto its field of scalars.
If you think of $\mathbb{X}^n$ as a space of vector valued functions $X:\Omega_{X}^n \rightarrow E_{X}^n$ over the field $\mathbb{R}^n$ then it should be clear that the functional $E[X]$ maps a function to a member of its field of scalars.
A: The expectation of a random variable is a property of that random variable.  If we want to be more formal we could (as qing78 suggests) formalize expectation $E$ as an operator or functional that maps a random variable to a value.  It would have signature  $E: \chi \to \mathbb{R}$ where $\chi$ is the space of random variables.  $E$ is a functional (or operator, or higher-order function in programming languages terminology) because elements in its domain are random variables, which are technically functions.
Functionals are functions and so from that perspective the answer to your question is yes.  $E$ is a function.
On the other hand, most probabilists would take "a function of a random variable" to mean a function of its output, as explained by P. Michaels, and hence would not consider a random variable to be a function.  In this case, if you have a random variable $X: \Omega \to \mathbb{R}$ and a function such as $\sin$ then $\sin(X)$ is a random variable defined as $\omega \mapsto \sin(X(\omega))$.  In words, its like $X$ but with $\sin$ applied to the output.  In general, this is called the pointwise application of $\sin$ to $X$.
