Solution (source code)

= Solution

For the <binomial distribution> and $T\geq1$, the identity $s\binom Ts=T\binom{T-1}{s-1}$ gives the <expectation>
$$
\mathbb ES=\sum_{s=1}^Ts\binom Ts p^s(1-p)^{T-s}
=Tp\sum_{r=0}^{T-1}\binom{T-1}r p^r(1-p)^{T-1-r}=Tp.
$$
The final sum is one by the <binomial theorem>. For $T=0$ the variable is identically zero, so the same answer holds:
$$
\boxed{\mathbb ES=Tp.}
$$