In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
h=3; #miller indices with respect to x axis
k=1; #miller indices with respect to y axis
l=1; #miller indices with respect to z axis
a=2.109*10**-10; #lattice constant of plane in a simple cubic lattice(m)
#Calculation
d=(a/(math.sqrt(h**2+k**2+l**2))); #The interplanar distance(m)
#Result
print "The interplanar distance is",round(d*10**11,4),"*10**-11 m"
```

In [5]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
h=1; #miller indices with respect to x axis
k=1; #miller indices with respect to y axis
l=0; #miller indices with respect to z axis
d=2.86*10**-10; #the distance between miller indices(m)
#Calculation
a=(d*(math.sqrt(h**2+k**2+l**2))); #The lattice constant(m)
#Result
print "The lattice constant is",round(a*10**10,4),"*10**-10 m"
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
h=1; #miller indices of x-axis
k=1; #miller indices of y-axis
l=1; #miller indices of z-axis
#Calculation
p=1/h; #intercept on x-axis
q=1/k; #intercept on y-axis
r=1/l; #intercept on z-axis
#Result
print "The ratio of intercepts on the three axis by (",h,k,l,") plane is",p,":",q,":",r
```

In [11]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
r=1.246*10**-10; #atomic radius of Fcc crystal(m)
h1=1; #miller indices with respect to x axis in 1st plane
k1=1; #miller indices with respect to y axis in 1st plane
l1=1; #miller indices with respect to z axis in 1st plane
h2=2; #miller indices with respect to x axis in 2nd plane
k2=0; #miller indices with respect to y axis in 2nd plane
l2=0; #miller indices with respect to z axis in 2nd plane
h3=2; #miller indices with respect to x axis in 3rd plane
k3=2; #miller indices with respect to y axis in 3rd plane
l3=0; #miller indices with respect to z axis in 3rd plane
#Calculation
a=(4*r)/math.sqrt(2); #The lattice constant in a FCC crystal(m)
d1=(a/(math.sqrt(h1**2+k1**2+l1**2))); #inter planar spacing distance in 1st plane(m)
d2=(a/(math.sqrt(h2**2+k2**2+l2**2))); #inter planar spacing distance in 2nd plane(m)
d3=(a/(math.sqrt(h3**2+k3**2+l3**2))); #inter planar spacing distance in 3rd plane(m)
#Result
print "The inter planar spacing distance in 1st plane is",round(d1*10**10,4),"*10**-10 m"
print "The inter planar spacing distance in 2nd plane is",round(d2*10**10,4),"*10**-10 m"
print "The inter planar spacing distance in 3rd plane is",d3,"m"
```

In [21]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=1; #assume
h1=1; #miller indices with respect to x axis in 1st plane
k1=0; #miller indices with respect to y axis in 1st plane
l1=0; #miller indices with respect to z axis in 1st plane
h2=1; #miller indices with respect to x axis in 2nd plane
k2=1; #miller indices with respect to y axis in 2nd plane
l2=0; #miller indices with respect to z axis in 2nd plane
h3=1; #miller indices with respect to x axis in 3rd plane
k3=1; #miller indices with respect to y axis in 3rd plane
l3=1; #miller indices with respect to z axis in 3rd plane
#Calculation
x1=math.sqrt(h1**2+k1**2+l1**2);
d100=a/x1; #inter planar spacing distance in 1st plane(m)
x2=math.sqrt(h2**2+k2**2+l2**2);
d110=a/x2; #inter planar spacing distance in 2nd plane(m)
x3=math.sqrt(h3**2+k3**2+l3**2);
d111=a/x3; #inter planar spacing distance in 3rd plane(m)
#Result
print "The inter planar spacing distance in 1st plane is a*",d100,"m"
print "The inter planar spacing distance in 2nd plane is a*",round(d110,3),"m"
print "The inter planar spacing distance in 3rd plane is a*",round(d111,3),"fm"
print "Ratio of interplanar distance of three planes d100:d110:d111=",(1/x1),":",round((1/x2),3),":",round((1/x3),3)
```

In [23]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=1; #x-intercept of the plane
q=1/2; #y-intercept of the plane
r=3; #z-intercept of the plane
#Calculation
h=(1/p)*3; #miller indices with respect to x axis
k=(1/q)*3; #miller indices with respect to y axis
l=(1/r)*3; #miller indices with respect to z axis
#Result
print "The miller indices of the plane is (h k l)=(",h,k,l,")"
```

In [24]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=2.814; #the lattice constant of a simple cubic system(angstrom)
h1=1; #miller indices with respect to x axis
k1=0; #miller indices with respect to y axis
l1=0; #miller indices with respect to z axis
#Calculation
d=a/math.sqrt(h1**2+k1**2+l1**2); #inter planar d spacing distance(angstrom)
#Result
print "The inter planar d-spacing distance is",d,"angstrom"
```

In [26]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
OA=0.025; #The unit cell makes intercepts on a(nm)
OB=0.02; #The unit cell makes intercepts on b(nm)
OC=0.01; #The unit cell makes intercepts on c(nm)
a=0.05; #The unit cell edge of an orthorhombic crystal(nm)
b=0.04; #The unit cell edge of an orthorhombic crystal(nm)
c=0.03; #The unit cell edge of an orthorhombic crystal(nm)
#Calculation
p=a/OA; #miller indices with respect to x axis
q=b/OB; #miller indices with respect to y axis
r=c/OC; #miller indices with respect to z axis
#Result
print "The miller indices of the set of parallel lines is (",p,q,r,")"
```

In [36]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=0.424; #value of one axial unit
b=1; #value of second axial unit
c=0.367; #value of third axial unit
i1=0.212; #value at x-intercept
j1=1; #value at y-intercept
k1=0.183; #value at z-intercept
i2=0.848; #value at x-intercept
j2=1; #value at y-intercept
k2=0.732; #value at z-intercept
i3=0.424; #value at x-intercept
k3=0.123; #value at z-intercept
#Calculation
p1=1/(i1/a); #miller indices at x-intercept
q1=1/(j1/b); #miller indices at y-intercept
r1=1/(k1/c); #miller indices at z-intercept
p2=1/(i2/a)*2; #miller indices at x-intercept
q2=1/(j2/b)*2; #miller indices at y-intercept
r2=1/(k2/c)*2; #miller indices at z-intercept
p3=1/(i3/a); #miller indices at x-intercept
q3=0; #miller indices at y-intercept
r3=1/(k3/c); #miller indices at z-intercept
#Result
print "The miller indices are",int(p1),int(q1),int(r1)
print "The miller indices are",int(p2),int(q2),int(r2)
print "The miller indices are",int(p3),int(q3),round(r3)
```

In [39]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
OB=2; #The intercept made by the parrell line ,OB=2b
OC=7; #The intercept made by the parrell line ,OC=2c
#OA=infinite The intercept made by the parrell line ,OB=2b
#Calculation
A=0; #miller indice along x-axis
B=1/OB; #miller indice along y-axis
C=1/OC; #miller indice along z-axis
X=(B*(OC*OB)); #taking L.C.M
Y=(C*(OC*OB)); #taking L.C.M
#Result
print "Miller indices are (1/infinite 1/",OB,"1/",OC,")=",A,int(X),int(Y)
```

In [41]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=3.6; #lattice parameter of copper(angstrom)
#Calculation
r=(a*math.sqrt(2))/4; #The atomic radius of copper(angstrom)
#Result
print "The atomic radius of copper is",round(r,3),"angstrom"
```

In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=4.12; #the lattice constant of a simple cubic system(angstrom)
h1=3; #miller indices with respect to x axis
k1=2; #miller indices with respect to y axis
l1=1; #miller indices with respect to z axis
#Calculation
d=a/math.sqrt(h1**2+k1**2+l1**2); #inter planar d spacing distance(angstrom)
#Result
print "The inter planar d-spacing distance is",round(d,4),"angstrom"
```

In [40]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=4; #no.of atoms in FCC structure
A=63.54; #Atomic weight of copper
r=1.278*10**-10; #atomic radius(m)
N=6.023*10**26; #Avogadro's Number(per Kg mol)
#Calculation
a=(4*r/math.sqrt(2)); #The lattice constant(m)
d=A*n/(N*a**3); #The density of copper(Kg/m^3)
#Result
print "The density of copper is",int(d),"Kg/m^3"
print "answer varies due to rounding off errors"
```

In [41]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
h1=1; #miller indices with respect to x axis in 1st plane
k1=0; #miller indices with respect to y axis in 1st plane
l1=0; #miller indices with respect to z axis in 1st plane
h2=1; #miller indices with respect to x axis in 2nd plane
k2=1; #miller indices with respect to y axis in 2nd plane
l2=0; #miller indices with respect to z axis in 2nd plane
h3=1; #miller indices with respect to x axis in 3rd plane
k3=1; #miller indices with respect to y axis in 3rd plane
l3=1; #miller indices with respect to z axis in 3rd plane
a=1; #The lattice constant in a in a simple cubic lattice(m)
#Calculation
d100=a/math.sqrt(h1**2+k1**2+l1**2); #inter planar spacing distance in 1st plane(m)
d110=a/math.sqrt(h2**2+k2**2+l2**2); #inter planar spacing distance in 2nd plane(m)
d111=a/math.sqrt(h3**2+k3**2+l3**2); #inter planar spacing distance in 3rd plane(m)
#Result
print "The ratio of interplanar distance between successive lattice planes in a simple cubic lattice is d100:d110:d111=",int(d100),":",round(d110,3),":",round(d111,3)
```

In [42]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
x=23; #atomic weight of sodium
y=35.45; #atomic weight of chloride
AW=58.45; #atomic weight of sodium chloride(NaCl)
n=4; #no.of atoms in FCC structure
d=2.18*10**6; #density of NaCl crystal of FCC structure(kg/m^3)
N=6.023*10**23; #Avogadro's Number(per Kg mol)
#Calculation
a=(n*AW/(d*N))**(1/3); #The lattice constant(m)
r=a/2; #The distance between two adjacent atoms(m)
#Result
print "The distance between two adjacent atoms is",round(r*10**10,2),"*10**-10 m"
```

In [43]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=2; #no.of atoms in BCC structure
d=7.86*10**6; #density of iron of FCC structure(kg/m^3)
AW=55.85; #atomic weight of Fe
N=6.023*10**23; #Avogadro's Number(per Kg mol)
#Calculation
a=(n*AW/(d*N))**(1/3); #The lattice constant(m)
r=a*math.sqrt(3)*10**10/4; #The atomic radius of Fe which has BCC structure(angstrom)
#Result
print "The atomic radius of Fe which has BCC structure is",round(r,3),"angstrom"
```

In [44]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=4; #no.of atoms in FCC structure
d=2.7*10**3; #density of potassium bromide(Kg/m^3)
AW=119; #molecular weight of KBr
N=6.023*10**26; #Avagadro's number(Kg mol)
#Calculation
a=((n*AW/(d*N))**(1/3))*10**10; #The lattice constant(angstrom)
#Result
print "The lattice constant is",round(a,1),"angstrom"
```

In [45]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
d=9.6*10**2; #density of crystal(Kg/m^3)
AW=23; #molecular weight of the crystal
N=6.023*10**26; #Avagadro's number(per Kg mol)
a=4.3*10**-10; #lattice constant(m)
#Calculation
n=d*N*a**3/AW; #Number of atoms per unit cell of a crystal
#Result
print "Number of atoms per unit cell of a crystal is",round(n)
print "If n=2,the crystal system is body centered cubic"
```

In [46]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
r=1.2*10**-10; #atomic radius of crystal of BCC structure(m)
#Calculation
a=4*r/math.sqrt(3); #lattice constant of BCC structure(m)
V=a**3; #The volume of cell(m^3)
#Result
print "The volume of cell is",round(V*10**29,3),"*10**-29 m^3"
```

In [47]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=4*10**-7; #lattice constant of the crystal(mm)
h1=1; #miller indices with respect to x axis in 1st plane
k1=0; #miller indices with respect to y axis in 1st plane
l1=0; #miller indices with respect to z axis in 1st plane
#Calculation
n=4*(1/4); #Number of atoms contained in a plane per unit cell
A=a**2; #Area of the plane(mm^2)
d=n/A; #The planar atomic density(atoms/mm^2)
#Result
print "The planar atomic density is",d,"atoms/mm^2"
```

In [48]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=4; #no.of atoms in Face centered cubic lattice
d=6250; #density of potassium bromide(Kg/m^3)
AW=60.2; #molecular weight of crysal with face centered cubic lattice
N=6.023*10**26; #Avagadro's number(per Kg mol)
#Calculation
a=((n*AW/(d*N))**(1/3)); #The lattice constant(m)
#Result
print "The lattice constant is",round(a*10**10),"*10**-10 m"
```

In [50]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
r1=0.1258*10**-9; #atomic radii of the iron atom in BCC structure(m)
r2=0.1292*10**-9; #atomic radii of the iron atom in FCC structure(m)
T=910; #metallic iron changes from BCC to FCC(C)
#Calculation
a1=(4*r1/math.sqrt(3)); #lattice constant of BCC structure(m)
v1=a1**3/2; #The volume occupied by one BCC atom(m^3)
a2=4*r2/math.sqrt(2); #lattice constant of FCC structure(m)
v2=a2**3/4; #The volume occupied by one FCC atom(m^3)
V=((v1-v2)/v1)*100; #The change in volume percentage
#Result
print "The change in volume percentage is",round(V,5)
print "answer varies due to rounding off errors"
```

In [52]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=0.405*10**-9; #lattice constant of unit cell of aluminium which is face centered cubic(m)
s=25*10**-2; #Side of aluminium foil(m)
t=0.005*10**-2; #Thickness of aluminium foil(m)
#Calculation
ar=s**2; #area of aluminium foil(m^2)
V=ar*t; #volume of the aluminium foil(m^3)
v=a**3; #volume of the unit cell(m^3)
n=(V/v); #Number of unit cells
#Result
print "The Number of unit cells is",round(n/10**22,5),"*10**22"
```

In [59]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
r=0.1605*10**-9; #radius of magnesium atom which has HCP structure(m)
#Calculation
a=2*r; #lattice constant of magnesium which has HCP structure(m)
c=a*math.sqrt(8/3); #height of the HCP structure(m)
V=3*math.sqrt(3)*(a**2)*c/3; #Volume of the unit cell of Magnesium which has HCP structure(m^3)
#Result
print "The Volume of the unit cell of Magnesium which has HCP structure is",round(V*10**28),"*10**-28 m^3"
print "answer given in the book is wrong"
```