Suppose random variable $X$ takes 3 values $1, 2, 3$ with probability $\frac{1}{3}$. Sample 1000 times from $X$ independently and do the following operations. Take a number $T=0$. If 1 comes, add 0.18 with $T$, if 2 comes add 0.05 with $T$ if 3 comes add -0.29 with $T$. It is clear expected value of $T$ is $\frac{(0.18+0.05-0.29)1000}{3}=-20$. How to calculate variance of $T$? Experimentally I am getting around 38.75. This is my Sage code.
C= [0.18, 0.05, -0.29]
D=[]
for j in range(10000):
T=0
for i in range(N):
aa=random()
if(aa<=1/3):
T=T+C[0]
if(aa>1/3 and aa<=2/3):
T=T+C[1]
if(aa>2/3):
T=T+C[2]
D.append(T)
print mean(D), variance(D)