For the first one the calculus makes sense $f= x^3-3x+1$. So consider $f' = 3x^2 -3$ which has zeros at $\pm 1$. Then $f(1) = -3$ is negative and $f(-1) = 1$ is positive. S we know it actually crosses the x-axis between $(-1,1)$. I'm not sure how we get from that there are 3 real roots?
Then for second one, $g= x^3-3x+7$, so obviously same derivative and zeros. Here though $g(1) = 5$ and $g(-1) = 9$ and I'm not sure where to go from there because the intersection actually happens between $(-3, -2)$ and that gives that we only have one real root which I also don't understand
HINT:
Consider graphing $ y = x^3-3 x + A $ for some values of A. The chosen value of A has the effect of raising or lowering entire graph along y-direction.
Find two values of A $ ( A_{min},A_{max} )$ so that the graph touches x-axis. To satisfy this,
$$ y = 0, y^{'}=0 $$
Inside this interval of A there are 3 real roots. Outside the interval, it has one real root, two complex roots.