#importing modules
import math
from __future__ import division
#Variable declaration
theta = 15; #angle of reflection(degrees)
d = 2.5; #atomic spacing(angstrom)
n = 1; #first order
#Calculation
d = d*10**-10; #atomic spacing(m)
theta = theta*math.pi/180; #angle of reflection(radian)
lamda = 2*d*math.sin(theta)/n; #wavelength of X-rays(m)
#Result
print "wavelength of X-rays is",round(lamda/1e-10,3),"*10**-10 m"
#importing modules
import math
from __future__ import division
#Variable declaration
two_theta = 20; #angle of reflection(degrees)
d = 2.82; #atomic spacing(angstrom)
n = 1; #first order
#Calculation
theta = two_theta/2;
theta = theta*math.pi/180; #angle of reflection(radian)
lamda = 2*d*math.sin(theta)/n; #wavelength of X-rays(angstrom)
lamda = math.ceil(lamda*10**4)/10**4; #rounding off to 4 decimals
#Result
print "wavelength of X-rays is",lamda,"angstrom"
#importing modules
import math
from __future__ import division
#Variable declaration
lamda = 10; #wavelength(pm)
phi = 45; #scattering angle(degrees)
h = 6.62*10**-34; #planck's constant(m**2 kg/s)
m0 = 9.1*10**-31; #mass(kg)
c = 3*10**8; #velocity of light(m/s)
ev = 6.24*10**18; #conversion factor from J to eV
#Calculation
phi = phi*math.pi/180; #scattering angle(radian)
a = h/(m0*c); #value of constant(m)
a = a*10**12; #value of constant(pm)
lamda_dash = lamda+(a*(1-math.cos(phi))); #wavelength of X-rays(pm)
lamda_dash = math.ceil(lamda_dash*10**2)/10**2; #rounding off to 2 decimals
lamdadash = lamda+(2*a); #maximum wavelength of scattered x-rays(pm)
lamdadash = math.ceil(lamdadash*10)/10; #rounding off to 1 decimal
KE = h*c*((1/lamda)-(1/lamdadash))/(10**-12); #maximum kinetic energy(J)
KE = KE*ev; #maximum kinetic energy(eV)
KE = KE*10**-3; #maximum kinetic energy(KeV)
KE = math.ceil(KE*10)/10; #rounding off to 1 decimal
#Result
print "wavelength of X-rays scattered is",lamda_dash,"pm"
print "maximum wavelength of scattered x-rays is",lamdadash,"pm"
print "maximum kinetic energy is",KE,"KeV"
#importing modules
import math
from __future__ import division
#Variable declaration
h = 6.62*10**-34; #planck's constant(m**2 kg/s)
m0 = 9.1*10**-31; #mass(kg)
c = 3*10**8; #velocity of light(m/s)
phi = 180; #scattering angle(degrees)
#Calculation
phi = phi*math.pi/180; #scattering angle(radian)
a = h/(m0*c); #value of constant(m)
a = a*10**10; #value of constant(angstrom)
delta_lamda = a*(1-math.cos(phi)); #change in wavelength(angstrom)
delta_lamda = math.ceil(delta_lamda*10**4)/10**4; #rounding off to 4 decimals
#Result
print "change in wavelength of photon is",delta_lamda,"angstrom"
print "answer in the book varies due to rounding off errors"
#importing modules
import math
from __future__ import division
#Variable declaration
h = 6.62*10**-34; #planck's constant(m**2 kg/s)
m0 = 9.1*10**-31; #mass(kg)
c = 3*10**8; #velocity of light(m/s)
phi = 90; #scattering angle(degrees)
#Calculation
phi = phi*math.pi/180; #scattering angle(radian)
a = h/(m0*c); #value of constant(m)
a = a*10**10; #value of constant(angstrom)
lamda = a*(1-math.cos(phi)); #wavelength(angstrom)
lamda = math.ceil(lamda*10**5)/10**5; #rounding off to 5 decimals
E = h*c/(lamda*10**-10); #energy of photon(J)
#Result
print "wavelength of the photon is",lamda,"angstrom"
print "energy of the incident photon is",round(E/1e-14,4),"*10**-14 J"
print "answer for energy of incident photon is wrong in the book"