I know how to solve it when it is homogeneous and the initial conditions the constants are 0 .But how to solve it when there is some non-homogeneous part. Any help will be appreciated. Thanks in advance.
The problem is
$$ \alpha \frac{\partial T}{\partial t}= \frac{\partial^{2} T}{\partial x^{2}}+10x\sin(t) $$
given the following conditions
$$ 0 \leq x \leq 1 \\ t \geq 0 \\ BC1 : T(0,1) =10 \\ BC2 : T(1,t) = 20 \\ IC1 : T(x,0) = 10 $$
Making boundary conditions homogeneous
You cane use a support variable, call it $$\tilde{u} = u-10x-10\tag1$$ which you can easily see that it's still a solution to the PDE $$\alpha\frac{\partial u}{\partial t} = \frac{\partial^2 u}{\partial x^2}+10x\sin t\tag2$$ in fact $$\partial_t \tilde{u} = \partial_t u -\underbrace{\partial_t (10x+10)}_{\text{is zero}} = \partial_t u \\ \partial^2_{xx}\tilde{u} = \partial_{xx}^2u-\partial_{xx}^2(10x+10) = \partial_{xx}^2u$$ so clearly from if $u$ is a solution to $(2)$ then $\tilde{u}$ is a solution to $$\alpha\partial_t \tilde{u} =\partial^2_{xx}\tilde{u}+10x\sin t$$ The benefit to this is that the boundary and initial conditions change when you solve the equation for $\tilde u$, in fact, from the definition $(1)$ you get $$\tilde u(0, t) = u(0,t)-10(0)-10 = 10-10= 0 \\ \tilde u(1,0) = u(1,t)-10(1)-10 = 20-20 = 0 \\ \tilde u(x,0) = u(x,0)-10x-10 = 10-10x-10 = 10x$$ so in this new function you have homogeneous boundary conditions! Pretty convenient. And the initial condition gives you some insight on the Fourier series you should use: you need to expand the solutions in $\sin (t)$ functions (you could as easily see that from the new initial conditions).
Tro wrap up, now you need to solve the following PDE $$ \begin{cases} \alpha\partial_t \tilde u = \partial^2_{xx}\tilde u +10x\sin t \\ 0\leq x \leq 1\;\;\; t\geq 0\\ \tilde u(0,t)=\tilde u (1,t) = 0\\ \tilde u (x,0) = 10x\end{cases}\tag 3$$ if you solve this then you can easily go back to the function $u$ by the definition $(1)$.
Solving PDE
Now to solve the $(3)$ PDE we can easily use the Fourier method. First suppose that the function $\tilde u$ is of the form $$\tilde u (x,t) = \sum_n a_n(x)\sin(n t)+b_n(x)\cos (n t)$$ and substitute it back into the PDE $(3)$ getting $$\partial_t \tilde u = \sum_n (n a_n(x)\sin(n t) - n b_n(x)\cos(n t))\\ \partial_{xx}^2\tilde u = \sum_n (a''_n(x)\sin(n t)+ b''_n(x)\cos(nt))\\ 10x\sin t = \sum_n\delta_{1n} 10nx\sin(nt)$$ so then $$\sum_n \alpha(n a_n(x)\cos(n t) - n b_n(x)\sin(n t)) = \sum_n (a''_n(x)\sin(n t)+ b''_n(x)\cos(nt))+\sum_n\delta_{1n} 10nx\sin(nt)$$ so now we have to solve the system of ODE's in $a(x)$ and $b(x)$, mainly $$\begin{cases} a''_n(x) = -n\alpha b_n(x)-\delta_{1n}10x \\ b''_n(x) = n\alpha a_n(x) \end{cases}$$ This system can be solved by first writing it in matrix convention: we choose $$y(x) = \left(\begin{matrix}a_n(x)\\b_n(x)\end{matrix}\right) \implies y''(x) = \left(\begin{matrix}a''_n(x)\\b''_n(x)\end{matrix}\right)\\ f(x) = \left(\begin{matrix}\delta_{n1}10x\\0\end{matrix}\right) \\ A = \left(\begin{matrix}0&-n\alpha \\n\alpha&0 \end{matrix}\right) $$ so that the system becomes $$y''(x) = Ay(x)+f(x)$$ From now on is "just" matter of solving this system of differential equations.
Sorry for the long post and if I made any mistakes let me know! Probably there's an easier way to solve the PDE but this was the best I could come up with for the moment. The idea behind making boundary condition homogeneous is still valid: just try to find a function that solves the equation but with homogeneous boundary conditions.