The expected basic algorithm is to multiply each possible value of a random variable by the corresponding probability, and then add it.
Here e (-2x) is equivalent to all possible values of y, and f(x) is the probability corresponding to each value, so the integration is naturally expected.
You can calculate the distribution density of y first, but needless to say, if you calculate the distribution density of y as g(y), you still have to integrate yg(y) and multiply it. The direct integral of g(y) must be 1.