For the answer to the question above, For n = 2:
The smallest value of f(x) on [0, π/2] is 2, which occurs at x = 0. The smallest value of f(x) on [π/2, π] is also 0, which occurs at x = π. So the lower sum is (π/2)(2 + 2) = 2π
The largest value of f(x) on [0, π/2] is 3, which occurs at x = π/2. This is also true for the interval [π/2, π]. So the upper sum is (π/2)(3 + 3) = 3π
n = 4:
Note that f '(x) = cos(x), which is positive for [0, π/2) and negative for (π/2, π]. This tells us that f is an increasing function on [0, π/2) and a decreasing function on (π/2, π]. So for the lower sum you will always evaluate f at the left endpoint of the sub-interval if that subinterval lies in [0, π/2], and at the right endpoint of the sub-interval if it lies in [π/2, π]
Thus, the lower sum for n = 4 is
(π/4)(f(0) + f(π/4) + f(3π/4) + f(π))
and the upper sum is
(π/4)(f(π/4) + f(π/2) + f(π/2) + f(3π/4)).
I have no doubt that you will now be able to do the n = 8 case on your own.