I am trying to derive the expectation value $E[X]$ and variance $Var(X)$ of a binomial distribution for the random variable $X$ with $X \backsim B(n,p)$.
I know that $E[X] = \sum_\limits{i=0}^n x_ip_i$ and $Var(X) = E[X^2] - E[X]^2$, but don't know how to start with it.
I would say that it's easier to solve this when you think of the binomial distribution as the sum of iid Bernoulli trials. So $X = Y_1 + \ldots Y_n$ with $Y_i \sim \operatorname{Ber}(p)$. Then $$E[X] = E\left[Y_1 + \ldots +Y_n \right] = E[Y_1] + \ldots + E[Y_n] = p + \ldots + p = np$$
Replace $E[\cdot]$ with $\operatorname{Var}(\cdot)$ and the same thing happens again.