In [1]:

```
#importing modules
from __future__ import division
import math
#Variable declaration
D = 50; #Distance between source and the screen(cm)
lamda = 6563; #Wavelength of light of parallel rays(A)
d = 0.385; #Width of the slit(mm)
n1 = 1; #Order of diffraction for first minimum
n2 = 5; #Order of diffraction for fifth minimum
#Calculation
lamda = lamda*10**-8; #Wavelength of light of parallel rays(cm)
d = d*10**-1; #Width of the slit(cm)
#As sin(theta1) = n*lambda/d = x1/D, solving for x1
x1 = n1*lamda*D/d; #Distance from the centre of the principal maximum to the first minimum(cm)
x1 = x1*10; #Distance from the centre of the principal maximum to the first minimum(mm)
x1 = math.ceil(x1*10**3)/10**3; #rounding off the value of x1 to 3 decimals
x2 = n2*lamda*D/d; #Distance from the centre of the principal maximum to the fifth minimum(cm)
x2 = x2*10; #Distance from the centre of the principal maximum to the fifth minimum(mm)
x2 = math.ceil(x2*10**3)/10**3; #rounding off the value of x2 to 3 decimals
#Result
print "The Distance from the centre of the principal maximum to the first minimum is",x1, "mm"
print "The Distance from the centre of the principal maximum to the fifth minimum is",x2, "mm"
#answer for x2 given in the book is wrong
```

In [6]:

```
#importing modules
from __future__ import division
import math
#Variable declaration
D = 0.04; #Diameter of circular aperture(cm)
f = 20; #Focal length of convex lens(cm)
lamda = 6000; #Wavelength of light used(A)
#Calculation
lamda = lamda*10**-8; #Wavelength of light used(cm)
#We have sin(theta) = 1.22*lambda/D = theta, for small theta
#For first dark ring
theta = 1.22*lamda/D; #The half angular width at central maximum(rad)
r1 = theta*f; #The half width of central maximum for first dark ring(cm)
r1 = r1*10**2;
#We have sin(theta) = 5.136*lambda/(%pi*D) = theta, for small theta
#For second dark ring
theta = 5.136*lamda/(math.pi*D); #The half angular width at central maximum(rad)
r2 = theta*f; #The half width of central maximum for second dark ring(cm)
r2 = r2*10**2;
r2 = math.ceil(r2*100)/100; #rounding off the value of r2 to 2 decimals
#Result
print "The radius of first dark ring is",r1,"*10**-2 cm"
print "The radius of second dark ring is",r2,"*10**-2 cm"
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n = 2; #Order of diffraction
lamda = 650; #Wavelength of light used(nm)
d = 1.2*10**-3; #Distance between two consecutive slits of grating(cm)
#Calculation
#We have sin(theta) = n*N*lambda = n*lambda/d, solving for theta
lamda = lamda*10**-9; #Wavelength of light used(m)
d = d*10**-2; #Distance between two consecutive slits of grating(m)
a=n*lamda/d;
theta = math.asin(a); #Angle at which the 650 nm light produces a second order maximum(rad)
theta = theta*57.2957795; #angle in degrees
theta = math.ceil(theta*10**2)/10**2; #rounding off the value of theta to 2 decimals
#Result
print "The angle at which the light produces a second order maximum is",theta, "degrees"
```

In [8]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
lamda = 650; #Wavelength of light used(nm)
N = 6000; #Number of lines per cm on grating
theta = 90; #Angle at which the highest spectral order is obtained(degrees)
#Calculation
theta = theta*0.0174532925; #Angle at which the highest spectral order is obtained(rad)
#We have sin(theta) = n*N*lambda, solving for n
lamda = lamda*10**-9; #Wavelength of light used(m)
N = N*10**2; #Number of lines per m on grating
n = math.sin(theta)/(N*lamda); #The highest order of spectra with diffraction grating
n = math.ceil(n*10**3)/10**3; #rounding off the value of theta to 3 decimals
i,d = divmod(n, 1); #divides the value of n into integer and decimal parts where i is integer
#Result
print "value of n is",n
print "The highest order of spectra obtained with diffraction grating is",i
```

In [9]:

```
#importing modules
import math
#Variable declaration
N = 4000; #Number of lines per cm on grating
#For Blue Line
lamda1 = 450; #Wavelength of blue light(nm)
n1 = 3; #Order of diffraction spectrum
#For Red Line
lamda2 = 700; #Wavelength of red light(nm)
n2 = 2; #Order of diffraction spectrum
#Calculation
N = N*10**2; #Number of lines per m on grating
lamda1 = lamda1*10**-9; #Wavelength of blue light(m)
lamda2 = lamda2*10**-9; #Wavelength of red light(m)
#We have sin(theta) = n*N*lambda, solving for sin(theta)
sin_theta_3 = n1*N*lamda1; #Sine of angle at third order diffraction
sin_theta_2 = n2*N*lamda2; #Sine of angle at second order diffraction
#Result
print "Sine of angle at third order diffraction is",sin_theta_3
print "Sine of angle at second order diffraction is",sin_theta_2
#Check for overlapping
if (sin_theta_2-sin_theta_3)<0.05:
print "The two orders overlap"
else:
print "The two orders do not overlap"
```

In [10]:

```
#importing modules
import math
#Variable declaration
n = 1; #Order of diffraction spectrum
N = 6000; #Number of lines per cm on diffraction grating
D = 2; #Distance of screen from the source(m)
lamda1 = 400; #Wavelength of blue light(nm)
lamda2 = 750; #Wavelength of blue light(nm)
#Calculation
N = N*10**2; #Number of lines per m on grating
lamda1 = lamda1*10**-9; #Wavelength of blue light(m)
lamda2 = lamda2*10**-9; #Wavelength of blue light(m)
#We have sin(theta1) = n*N*lamda1, solving for theta1
theta1 = math.asin(n*N*lamda1); #Angle at first order diffraction for Blue light(rad)
theta1_d = theta1*57.2957795; #Angle at first order diffraction for Blue light(degrees)
theta2 = math.asin(n*N*lamda2); #Angle at first order diffraction for Red light(rad)
theta2_d = theta2*57.2957795; #Angle at first order diffraction for Red light(degrees)
x1 = D*math.tan(theta1); #Half width position at central maximum for blue color(m)
x2 = D*math.tan(theta2); #Half width position at central maximum for red color(m)
x = x2-x1; #width of first order spectrum on the screen(m)
x = x*10**2; #width of first order spectrum on the screen(cm)
x = math.ceil(x*10**2)/10**2; #rounding off the value of x to 2 decimals
#Result
print "The width of first order spectrum on the screen is",x, "cm"
```

In [11]:

```
#importing modules
import math
#Variable declaration
w = 5; #Width of the grating(cm)
N = 32; #Number of lines per mm on grating
lamda = 640; #Wavelength of light(nm)
n = 2; #Order of diffraction
#Calculation
N= N*10; #Number of lines per cm on grating
N0 = w*N; #Total number of lines on the grating
d_lambda = lamda/(n*N0); #Separation between wavelengths(nm)
#Result
print "The separation between wavelengths which the grating can just resolve is",d_lambda, "nm"
```

In [12]:

```
#importing modules
import math
#Variable declaration
lamda = 550; #Wavelength of light(nm)
D = 3.2; #Diameter of circular lens(cm)
f = 24; #Focal length of the lens(cm)
#Calculation
lamda = lamda*10**-9; #Wavelength of light(m)
D = D*10**-2; #Diameter of circular lens(m)
theta_min = 1.22*lamda/D; #Minimum angle of resolution provided by the lens(rad)
#As delta_x/f = theta_min, solving for delta_x
f = f*10**-2; #Focal length of the lens(m)
delta_x = theta_min*f; #Separation of the centres of the images in the focal plane of lens(m)
delta_x = delta_x*10**6; #Separation of the centres of the images in the focal plane of lens(micro m)
#Result
print "The separation of the centres of the images in the focal plane is",round(delta_x), "micro-metre"
```

In [13]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
lamda = 550; #Wavelength of light(nm)
D = 20; #Diameter of objective of telescope(cm)
d = 6; #Distance of two points from the objective of telescope(km)
#Calculation
lamda = lamda*10**-9; #Wavelength of light(m)
D = D*10**-2; #Diameter of objective of telescope(m)
d = d*10**3; #Distance of two points from the objective of telescope(m)
theta = 1.22*lamda/D; #Angular separation between two points(rad)
x = theta*d; #Linear separation between two points(m)
x = x*10**3; #Linear separation between two points(mm)
#Result
print "The linear separation between two points is",x, "mm"
```

In [ ]:

```
```