In [1]:

```
from math import *
#Variable declaration
i = 2e-003; # Current through X-ray tube, A
e = 1.6e-019; # Charge on an electron, C
V = 12.4e+003; # Potential difference applied across X-ray tube, V
m0 = 9.1e-031; # Rest mass of the electron, Kg
#Calculations&Results
n = i/e; # Number of electrons striking the target per second
print "The number of electrons striking the target per sec = %4.2e electrons"%n
v = sqrt(2*e*V/m0); # Velocity of the electrons, m/s
print "The speed with which electrons strike the target = %4.2e m/s"%v
```

In [2]:

```
from math import *
#Variable declaration
e = 1.6e-019; # Charge on an electron, C
V = 13.6e+003; # Potential difference applied across X-ray tube, V
m0 = 9.1e-031; # Rest mass of the electron, Kg
#Calculations
v = sqrt(2*e*V/m0); # Velocity of the electron, m/s
#Result
print "The maximum speed with which the electrons strike the target = %4.2e m/s"%v
```

In [3]:

```
from math import *
#Variable declaration
d = 2.82e-010; # Spacing of the rock-salt, m
n = 2; # Order of diffraction
#Calculations
theta = pi/2; # Angle of diffraction, radian
# Braggs equation for X-rays of wavelength lambda is n*lambda = 2*d*sin(theta), solving for lambda
lamda = 2*d*sin(theta)/n; # Wavelength of X-ray using Bragg's law, m
#Result
print "The longest wavelength that can be analysed by a rock-salt crystal = %4.2f angstrom"%(lamda/1e-010)
```

In [18]:

```
from math import *
#Variable declaration
lamda = 3e-011; # Wavelength of the X-ray, m
d = 5e-011; # Lattice spacing, m
#Calculations&Results
# Bragg's equation for X-rays of wavelength lambda is n*lambda = 2*d*sin(theta), solving for thetas
for n in range(2,4):
theta = degrees(asin((n*lamda)/(2*d)));
print "For n = %d, theta = %.1f degrees"%(n, theta)
```

In [19]:

```
from math import *
#Variable declaration
lamda = 3.6e-011; # Wavelength of X-rays, m
n = 1; # Order of diffraction
theta = 4.8; # Angle of diffraction, degrees
#Calculations
# Braggs equation for X-rays is n*lambda = 2*d*sin(theta), solving for d
d = n*lamda/(2*sin(theta*pi/180)); # Interplanar spacing, m
#Result
print "The interplanar separation of atomic planes in the crystal = %4.2f angstrom"%(d/1e-010)
```

In [20]:

```
#Variable declaration
lambda1 = 0.71; # Wavelength of k alpha line in molybdenum, angstrom
Z1 = 42; # Atomic number of Mo
Z2 = 29; # Atomic number of Cu
#Calculations
# Wavelength of characteristic X-ray for K-alpha spectral line is given by
# 1/lambda = 3/4*R*(Z-1)^2 then
lambda2 = lambda1*(Z1-1)**2/(Z2-1)**2; # The wavelength of K alpha radiation in copper, m
#Result
print "The wavelength of K-alpha radiation in copper = %4.2f angstrom"%lambda2
```

In [56]:

```
from math import *
#Variable declaration
phi = pi/2; # Scattering angle, degrees
m0 = 9.1e-031; # Rest mass of an electron, kg
h = 6.62e-034; # Planck's constant, J-s
c = 3e+008; # Speed of light in vacuum, m/s
E = 8.16e-014; # Energy of gamma radiation, J
#Calculations
lamda = h*c/(E*1e-010); # Wavelength of incident photon, angstrom
lambda_prime = lamda+h*(1-cos(phi*pi/180))/(m0*c*1e-010); # Wavelength of scattered photon, angstrom
#Result
print "The wavelength of radiation at 90 degrees = %6.4f angstrom"%(lambda_prime+lamda)
```

In [54]:

```
from math import *
#Variable declaration
phi = 90; # Scattering angle, radian
m0 = 9.1e-031; # Rest mass of the electron, kg
h = 6.62e-034; # Planck's constant, J-s
c = 3e+008; # Speed of light in vacuum, m/s
lamda = 1.00 ; # Wavelength of incident photon,in angstrom
#Calculations
del_lambda = (h*(1-round(cos(degrees(phi))))/(m0*c))/10**-10; # Compton shift, angstrom
#Result
print "The Compton shift = %.4f angstrom"%del_lambda
```

In [55]:

```
from math import *
#Variable declaration
phi = pi/2; # Scattering angle, radian
m0 = 9.1e-031; # Rest mass of the electron, kg
h = 6.62e-034; # Planck's constant, J-s
c = 3e+008; # Speed of light in vacuum, m/s
#Calculations
# As Compton shift = del_lambda = lambda, so
lamda = h*(1-cos(phi))/(m0*c*1e-010); # Wavelength of incident photon, angstrom
#Result
print "The wavelength of incident radiation = %6.4f angstrom"%lamda
```