Let $g$ be a function defined on the interval $[0,2]$ and $x \le g(x) \le x^2-x+1$ for $0 \le x \le 2$. Then
$(A)$ $g$ must be a polynomial.
$(B)$ $g$ must be continuous at $x = 1$.
$(C)$ $g$ must be continuous at $x = 0$ and $x = 2$.
$(D)$ $g$ must be a continuous function.
Since $\lim_{x\to 1} x = 1$ and $\lim_{x\to 1} x^2 - x + 1 = 1$. So by sandwich rule of functions $g$ is continuous at $x = 1$. So $B$ option is right.
Since $\lim_{x\to 0} x = 0$ and $\lim_{x\to 0} x^2 - x + 1 = 1$. So I am not able to conclude anything about continuity at $x = 0$.
Further I draw the graph of $x$ and $x^2 - x + 1$ and conclude that we can define a function satisfy given condition is possible but i did not define this function. So Plz help me to check out other options.
You have already proved (B) is correct. For the other ones, consider the function $$g(x)=\begin{cases} 1 & \text{if } x=0\\ x &\text{if } x\in (0,2) \\ 3 & \text{if } x= 2\end{cases}$$