We have $X\sim Bin(n,p)$
Now we have to determine the expected value of the quadratic random variable $X$
$$E\left[X^2 \right]$$
The expected value of binomial distribution is $E\left[X \right]=np$
The expected value of discrete random variable is $E\left[X \right]=\sum_{i\in S}a_iP(X=a_i)$
They told me to use sums instead of the $X$. We didn't introduce the variance.
Does that mean I have to replace $E\left[X^2 \right]$ with $E\left[\left(\sum_{i\in S}x_iP(X=a_i\right)^2\right]$?
$$E\left[\left(\sum_{i\in S}x_iP(X=a_i)\right)^2\right]=\left(\sum_{n=0}^k\binom{n}{k}p^k\cdot q^{n-k}\right)^2$$
I'm not quite sure if this is the correct approach.
Computing the following $$ \mathbb{E}\left[g(X)\right] = \sum_{i\in S}g(x_i)p(x_i) $$ so it is clear to see that we are not using the square of the probability distribution but instead just the square of the $X$.
Also, be consistent i.e. when you define $\mathbb{E}(X) = \sum a_i P(X=a_i)$ then make $\mathbb{E}(X^2) = \sum a_i^2 P(X=a_i)$