In order to calculate the expected value of x, we just need to divide the total number of lemon-flavored candies by the total number of bags, so we have:
[tex]\begin{gathered} E(x)=\frac{29\cdot1+69\cdot4+108\cdot5+118\cdot4+162\cdot5+167\cdot4+186\cdot2}{1+4+5+4+5+4+2} \\ E(x)=\frac{3167}{25} \\ E(x)=126.68 \end{gathered}[/tex]So the expected value of x is 126.68.