ψ[n_,l_,x_]:= Sqrt[2/l] Sin[n Pi x/l]

X= # x &

X2 = # x^2 &

P = - I ℏ D[#,x] &

P2 = -  ℏ^2 D[#,x,x] &

N[Simplify[Sqrt[Integrate[ψ[1,l,x] X2@ψ[1,l,x],{x,0,l}]-Integrate[ψ[1,l,x] X@ψ[1,l,x],{x,0,l}]^2] 
Sqrt[Integrate[ψ[1,l,x] P2@ψ[1,l,x],{x,0,l}]-Integrate[ψ[1,l,x] P@ψ[1,l,x],{x,0,l}]^2]]]