Calculate $\sum_{k=0}^n k \binom{n}{k} p^k (1-p)^{n-k}$ For $p \in [0,1]$ calculate
$$S =\sum_{k=0}^n k \binom{n}{k} p^k (1-p)^{n-k}.$$

Since
$$ (1-p)^{n-k} = \sum_{j=0}^{n-k} \binom{n-k}{j} (-p)^j, $$
then
$$ S =\sum_{k=0}^n \sum_{j=0}^{n-k} k \dfrac{n!}{k!j!(n-k-j)!} p^k (-p)^j. $$
If it weren't for that $k$, I would have
$$ S = (1+p-p)^n = 1\ldots $$
 A: We have the binomial expansion
$$
(p+q)^n=\sum_{k=0}^n\binom{n}{k}p^kq^{n-k}.
$$
Differentiating with respect to $p$ we get
$$
n(p+q)^{n-1}=\sum_{k=0}^nk\binom{n}{k}p^{k-1}q^{n-k}
$$
and hence
$$
np(p+q)^{n-1}=\sum_{k=0}^nk\binom{n}{k}p^{k}q^{n-k}.
$$
Setting $q=1-p$ above we finally obtain
$$
np=\sum_{k=0}^nk\binom{n}{k}p^{k}(1-p)^{n-k}.
$$
A: Use the identity $k\binom{n}{k}=n\binom{n-1}{k-1}$ and the binomial identity to get
$$
\begin{align}
\sum_{k=0}^nk\binom{n}{k}p^k(1-p)^{n-k}
&=\sum_{k=1}^nn\binom{n-1}{k-1}p\,p^{k-1}(1-p)^{n-k}\\
&=np\sum_{k=1}^n\binom{n-1}{k-1}p^{k-1}(1-p)^{n-k}\\
&=np\,(p+(1-p))^{n-1}\\[12pt]
&=np
\end{align}
$$
A: An answer from the point of view of probability theory rather than logic is as follows.
Let $X_1,\ldots,X_n$ be independent random variables, each equal to $1$ with probability $p$ and to $0$ with probability $1-p$.
The probability that exactly $k$ of them are equal to $1$ is $\dbinom n k p^k (1-p)^{n-k}$.  The expected number of them that are equal to $1$ is therefore $\displaystyle\sum_{k=0}^n k\binom n k p^k (1-p)^{n-k}$.
But the expected value is
$$
\mathbb E(X_1+\cdots+X_n) = \mathbb E(X_1)+\cdots+\mathbb E(X_n) = p + \cdots + p = np.
$$
