#initation of variable
#parta
from math import pi, sin
import math
from scipy import integrate
h=1.05*10**-34;m=9.11*10**-31;L=10.0**-10; # all the values are taken in SI units
E1=h**2*pi**2/(2*m*L**2); E2=4*E1; #Energies are calculated
delE=(E2-E1)/(1.6*10**-19); #Difference in energy is converted to eV
#result
print "Energy to be supplied in eV. is ",round(delE,3);
#partb
x1=0.09*10**-10;x2=0.11*10**-10 #limits of the given region
def integrand(x,L):
return 2.0/L*(sin(pi*x/L))**2
probGnd=integrate.quad(integrand,x1,x2,args=(L))
#result
print "The percentage probablility of finding an electron in the ground state is \n",round(probGnd[0]*100,3);
#partc
k1=0.0;k2=0.25*10**-10;
def integrand(k,L):
return 2.0/L*(sin(2*pi*k/L))**2
probExc=integrate.quad(integrand,k1,k2,args=(L))
#result
print "The probablility of finding an electron in the excited state is",round(probExc[0],3);