In [1]:

```
#Example 18_1
import math
#To find the force on the wire
b=2*10**-4 #Units in T
i=20 #Units in A
l=0.3 #Units in meters
theta=53 #Units in degrees
thetaa=math.sin(theta*math.pi/180) #Units in Radians
f=b*i*l*thetaa #Units in N
print "The force on the wire is F=",round(f,9)," N"
```

In [2]:

```
#Example 18_2
import math
#To find the magnitude of the magnetic field
m=1.67*10**-27 #Units in Kg
v=10**6 #Units in meters/sec
r=4*10**-2 #Units in Meters
q=1.6*10**-19 #Units in C or eV
b=(m*v)/(r*q) #Units in T
print "The magnitude of magnetic field is B=",round(b,4)," T"
```

In [4]:

```
#Example 18_3
import math
#To show that the particles does not deflect from its straight line path
print "The magnetic field exerts a force of q*v*B upwards on the particle.\nThe particle doesnot deflect because the two forces are equal\nHence v=(E/B)\nA particle with this speed will pass through the region of the crossfields and undeflected"
```

In [5]:

```
#Example 18_4
import math
#To calculate the value of B at a radial distance of 5 cm
u=4*math.pi*10**-7 #Units in T m/A
i=30 #Units in A
r=0.05 #Units in Meters
b=(u*i)/(2*math.pi*r) #Units in T
b=b*10**4 #Units in G
print "The value of B is=",round(b,2)," G"
```

In [6]:

```
#Example 18_5
import math
#To find the magnetic moment of hydrogen atom
r=0.53*10**-10 #Units in meters
a=math.pi*r**2 #Units in meters**2
q=1.6*10**-19 #Units in C
f=6.6*10**15 #Units in sec**-1
i=q*f #Units in A
u=i*a #Units in A meter**2
print "The magnetic moment of Hydrogen atom is="
print round(u,27)
print "A meters**2"
```