For your first question, the values of P(X) at x = 0, 1, and 2 are given to you from which you find

To find the mean (of a discrete distribution), which is also called theExpected Valueof x:

As stated by your question, this discrete random variable X takes the values 0, 1 and 2. Then the Mean or the Expected Value is calculated by multiplying each x value by its probability and summing them up.

The expected value or the mean of a continuous random variable, X, that has a value between a and b(In this case, 0 and 1) is computed by integrating x times its probability density function (p.d.f.) over the interval [a,b]. Your pdf here is f(x)=2x over the interval[0,1]: