#importing modules
import math
from __future__ import division
#Variable declaration
d=1.181; #lattice spacing(angstrom)
theta=90*math.pi/180; #glancing angle(radian)
lamda=1.540; #wavelength of X-rays(angstrom)
#Calculation
n=2*d*math.sin(theta)/lamda; #maximum order of diffraction
#Result
print "maximum order of diffraction is",round(n,2)
#importing modules
import math
from __future__ import division
#Variable declaration
n=1; #order
theta=9.5*math.pi/180; #glancing angle(radian)
lamda=0.58; #wavelength(angstrom)
h=2;
k=0;
l=0;
#Calculation
d=n*lamda/(2*math.sin(theta)); #lattice parameter(angstrom)
a=d*math.sqrt(h**2+k**2+l**2); #cube edge of unit cell(angstrom)
#Result
print "cube edge of unit cell is",round(a,3),"angstrom"
print "answer given in the book varies due to rounding off errors"
#importing modules
import math
from __future__ import division
#Variable declaration
theta=(8+(35/60))*math.pi/180; #glancing angle(radian)
lamda=0.842; #wavelength of X-rays(angstrom)
n1=1; #order
n3=3; #order
#Calculation
theta3=math.asin(n3*lamda*math.sin(theta)/(n1*lamda))*180/math.pi; #glancing angle for 3rd order(degrees)
theta3d=int(theta3); #glancing angle for 3rd order(degrees)
theta3m=(theta3-theta3d)*60; #glancing angle for 3rd order(minutes)
#Result
print "glancing angle for 3rd order is",theta3d,"degrees",int(theta3m),"minutes"
print "answer for minutes given in the book is wrong"
#importing modules
import math
from __future__ import division
#Variable declaration
theta=20.3*math.pi/180; #glancing angle(radian)
lamda=1.54; #wavelength of X-rays(angstrom)
n=1; #order
a=3.16; #lattice parameter(angstrom)
#Calculation
d=n*lamda/(2*math.sin(theta)); #interplanar spacing(angstrom)
x=(a/d)**2; #assume x=(h**2+k**2+l**2)
#Result
print "interplanar spacing is",round(d,2),"angstrom"
print "value of h**2+k**2+l**2 is",int(x)
print "miller indices are (110) or (011) or (101)"
#importing modules
import math
from __future__ import division
#Variable declaration
n=4; #order
A=107.87; #atomic weight(kg)
theta=(19+(12/60))*math.pi/180; #glancing angle(radian)
h=1;
k=1;
l=1;
N=6.02*10**26; #avagadro number
rho=10500; #density(kg/m**3)
H=6.625*10**-34; #plancks constant(Js)
c=3*10**8; #velocity of light(m/s)
e=1.6*10**-19; #charge(coulomb)
#Calculation
a=round(((n*A/(N*rho))**(1/3))*10**10,2); #lattice parameter(angstrom)
d=a/math.sqrt((h**2)+(k**2)+(l**2)); #lattice parameter(angstrom)
lamda=2*d*math.sin(theta); #wavelength(angstrom)
E=H*c/(lamda*10**-10*e); #energy of X-rays(eV)
#Result
print "wavelength is",round(lamda,3),"angstrom"
print "energy of X-rays is",int(round(E/10**3)),"*10**3 eV"
#importing modules
import math
from __future__ import division
#Variable declaration
h=1;
k=1;
l=1;
a=4.57; #lattice parameter(angstrom)
lamda=1.52; #wavelength(angstrom)
r=5; #radius(cm)
#Calculation
d=a/math.sqrt(h**2+k**2+l**2); #lattice parameter(angstrom)
theta=math.asin(lamda/(2*d)); #glancing angle(degrees)
X=r/math.tan(2*theta); #specimen distance(cm)
#Result
print "specimen distance is",round(X,3),"cm"
print "answer given in the book varies due to rounding off errors"