to show whether a complex function is constant given some boundary conditions If a function is analytic on $B(0,1)$ and continuous as well as real valued on the boundary (i.e. $|z| = 1$),then show that the function is constant.

Hint: apply the maximum principle for harmonic functions to imaginary part of your function.
Edit
As usual, we say that complelx variable $z$ writes $$z=x+iy$$
and the function $f$ has real and imaginary parts $u$ and $v$ respectively:
$$f(x+iy) = u(x,y)+iv(x,y).$$
It is a standard result that $u$ and $v$ are harmonic:
$$\Delta u = \Delta v =0 .$$
We can therefore apply the maximum principle (https://en.wikipedia.org/wiki/Maximum_principle) to the function $v$; it is identically zero on the boundary $x^2+y^2=1$, hence $v$ is identically zero on the whole unit ball $B(0,1)$.
After that, the Cauchy-Riemann condition $$\partial_x u = \partial_y v,\quad \partial_y u =-\partial_x v$$
assures us that $\nabla u =0$ and therefore $u$ is a constant function.
Thus, $f$ is constant.
