In [1]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
x = 5; #distance of 1st minimum(mm)
D = 2; #distance between lens and screen(m)
a = 0.2; #width of slit(mm)
#Calculation
x = x*10**-3; #distance of 1st minimum(m)
a = a*10**-3; #width of slit(m)
lamda = a*x/D; #wavelength of light(m)
#Result
print "wavelength of light is",lamda,"m"
```

In [8]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a = 0.2; #width of slit(mm)
lamda = 5*10**-7; #wavelength(m)
f = 50; #focal length(cm)
#Calculation
a = a*10**-3; #width of slit(m)
f = f*10**-2; #focal length(m)
theta_1 = lamda/a; #angular diffraction correcponding to 1st minima(radian)
theta_2 = 2*lamda/a; #angular diffraction correcponding to 2nd minima(radian)
x = f*(theta_2-theta_1); #separation between 1st and second minima(m)
x = x*10**2;
#Result
print "distance between first two minima on the screen is",x,"*10**-3 m"
```

In [13]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a = 0.16; #1st slit width(mm)
b = 0.8; #2nd slit width(mm)
#Calculation
nbym = (a+b)/a; #condition for missing orders
#Result
print "n = ",nbym,"m"
print "n = ",nbym,",",2*nbym,",",3*nbym,"etc for m = 1,2,3..."
```

In [14]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n = 2; #second order
theta = 30; #angle of diffraction(degrees)
lamda = 5*10**-5; #wavelength(cm)
#Calculation
theta = theta*math.pi/180; #angle of diffraction(radian)
aplusb = n*lamda/math.sin(theta);
N = 1/aplusb; #number of lines(per cm)
#Result
print "number of lines on the grating surface is",N,"per cm"
```

In [19]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
aplusb = 1.5*10**-6; #grating element(m)
lamda = 550; #wavelength(nm)
#Calculation
lamda = lamda*10**-9; #wavelength(m)
n = aplusb/lamda; #maximum possible order
n = math.ceil(n*10**3)/10**3; #rounding off to 3 decimals
#Result
print "maximum possible order is",n,". third and higher orders are not possible"
```

In [21]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
dlamda = 0.6; #difference in wavelength(nm)
lamda = 589.3; #wavelength(nm)
n = 1; #first order
#Calculation
N = lamda/(n*dlamda); #number of lines on grating
#Result
print "number of lines on grating is",int(N)
```