import math
from __future__ import division
#given
h=3;
k=2;
l=1; #miller indices
a=4.2E-8; #in cm (lattice constant)
#calculate
d=a/math.sqrt(h**2+k**2+l**2); #calculation for interplanar spacing
d=d*1E8; #changing unit from cm to Angstrom
#result
print"The interplanar spacing is d=",round(d,2),"cm";
print"\t\t\t d=",round(d,2),"Angstrom";
import math
from __future__ import division
#given
h=1;k=1;l=1; #miller indices
a=2.5;b=2.5;c=1.8; #in Angstrom (lattice constants for tetragonal lattice )
#calculate
d=1/math.sqrt((h/a)**2+(k/b)**2+(l/c)**2); #calculation for interplanar spacing
#result
print"The lattice spacing is d=",round(d,2),"Angstrom";
import math
from __future__ import division
#given
h=1;k=0;l=0; #miller indices
a=2.5; #in Angstrom (lattice constant)
#calculate
a=a*1E-10; #hence a is in Angstrom
d=a/math.sqrt(h**2+k**2+l**2); #calculation for interplanar spacing
p=d/a**3;
#result
print"The density is p=",round(p),"lattice points/m^2";