p0= 0.2;
p1= 0.5;
p2=0.3;
expec = 0*0*p0 + 1*1*p1 + 2*2*p2;
disp(expec, "Expectation of X^2 is")