In [1]:

```
#Question:
"""Finding the current necessary to produce a magnetic field inside the solenoid."""
from math import pi
#Variable Declaration:
B=20e-03 #Magnitude of magnetic field inside the solenoid(in Tesla)
n=20e02 #Number of turns per cm in the long solenoid
#Calculations:
abs_per=(4*pi)*(1e-07)
I=B/(abs_per*n)
#Result:
print "The required current is %.2f A." %(I)
```

In [4]:

```
#Question:
"""Finding the magnetic field near the centre and the ends of a solenoid."""
from math import pi
#Variable Declaration:
abs_per=4*pi*(1e-07) #Absolute permeability of free space(in Henry per metre)
I=6.0 #Current carried by the solenoid(in Amperes)
l=50e-02 #Length of solenoid(in metres)
r=1.4e-02 #Radius of the lowest layer(in metres)
turns_per_layer=350 #Number of turns per layer
number_of_layers=4 #Number of layers
#Calculations:
n=(turns_per_layer*number_of_layers)/l
B_centre=abs_per*n*I
B_end=(abs_per*n*I)/2
#Result:
print "(a)The magnetic field inside the solenois is quite uniform,its strength near the centre on its axis and"
print " off its axis is the same and its magnitude is %e T." %(B_centre)
print "(b)The magnetic field strength at the end of the solenoid is %e T." %(B_end)
print "(c)The magnetic field far outside the solenoid near its axis is negligible,compared to the internal field."
```

In [7]:

```
#Question:
"""Finding the force between two long straight parallel wires."""
from math import pi
#Variable Declaration:
r=2 #Distance between the parallel current carrying wires(in metres)
abs_per=(4*pi)*(1e-07) #Absolute permeability of free space(in Henry per metre)
I1=80 #Current in the first wire(in Amperes)
I2=30 #Current in the second wire(in Amperes)
#Calculations:
F=(abs_per*I1*I2)/(2*pi*r)
#Result:
print "The magnitude of the force between the two wires is %e N/m." %(F)
print "Since the two currents are in the same direction,the force will be attractive."
```

In [6]:

```
#Question:
"""Finding the force due to current flowing in two straight,parallel wires."""
from math import pi
#Variable Declaration:
I1=4.0 #Current in the first wire(in Amperes)
I2=6.0 #Current in the second wire(in Amperes)
r=3e-02 #Distance between the parallel current carrying wires(in metres)
abs_per=(4*pi)*(1e-07) #Absolute permeability of free space(in Henry per metre)
#Calculations:
F=(abs_per*I1*I2)/(2*pi*r)
l=15e-02
F_net=F*l
#Result:
print "The net force on 15cm(=0.15 m) section of wire B near its centre is %e N." %(F_net)
print "Since the currents are in opposite directions,the force F_net is repulsive."
print "It means that its direction is normal to wire A away from it."
```

In [8]:

```
#Question:
"""Finding the emf produced in a conductor placed in an uniform magnetic field."""
from math import sin,radians
#Variable Declaration:
B=0.5 #Magnitude of magnetic field(in Tesla)
l=20e-02 #Active length of the conductor(in metres)
v=5 #Velocity of the conductor(in metres per second)
#Calculations:
angle_a=0
e_a=B*l*v*sin(radians(angle_a))
angle_b=90
e_b=B*l*v*sin(radians(angle_b))
angle_c=30
e_c=B*l*v*sin(radians(angle_c))
#Result:
print "(a)The emf induced in the straight conductor when its motion is parallel to the magnetic field is %.2f V." %(e_a)
print "(b)The emf induced in the straight conductor when its motion is perpendicular to the magnetic field is %.2f V." %(e_b)
print "(c)The emf induced in the straight conductor when its motion is at an angle 30 degrees to the magnetic field is %.2f V." %(e_c)
```

In [12]:

```
#Question:
"""Finding the emf generated between the wing-tips of an aeroplane."""
from math import sin,radians
#Variable Declaration:
l=52 #Wing span of the aeroplane(in metres)
B=38e-06 #Magnitude of magnetic field(in Tesla)
v=1100.0*(1000.0/3600.0) #Velocity of the aeroplane(in metres per second)
angle=90 #Angle between the magnetic field vector and the velocity vector(in degrees)
#Calculations:
e=B*l*v*sin(radians(angle))
#Result:
print "The emf generated between the wing tips is %.5f V." %(e)
```

In [13]:

```
#Question:
"""Finding the emf developed between the centre and the metallic ring."""
from math import pi
#Variable Declaration:
""" A=(1/2)*R*R*theta; where theta is the angle between the rod and the rod OP(in figure) at time t """
B=1.0 #Magnitude of magnetic field(in Tesla)
R=1 #Radius of circular ring(in metres)
f=50 #Frequency of rotation(in revolutions per second)
""" B=d(flux)/dt= d(B*A)/dt= (1/2)*B*R*R*d(theta)/dt= (1/2)*B*R*R*ang_freq """
#Calculations:
ang_freq=2*pi*f
e=(1.0/2)*B*R*R*ang_freq
#Result:
print "The emf developed between the centre and the metallic ring is %.2f V." %(e)
```

In [15]:

```
#Question:
"""Finding the force needed to pull a rectangular loop placed in an uniform magnetic field."""
#Variable Declaration:
B=0.5 #Magnitude of magnetic field(in Tesla)
w=3e-02 #Width of the rectangular loop(in metres)
l=10e-02 #Length of the rectangular loop(in metres)
v=1e-02 #Velocity of the rectangular loop(in metre per second)
#Calculations:
e1=B*w*v
t1=l/v
e2=B*l*v
t2=w/v
R=1e-03
F_a=(pow((B*w),2)*v)/R
F_b=(pow((B*l),2)*v)/R
#Result:
print "(a)The induced emf is %e V and the time for which the induced voltage lasts is %.2f secs." %(e1,t1)
print "(b)The induced emf is %e V and the time for which the induced voltage lasts is %.2f secs." %(e2,t2)
print "(c)Because of the gap,no current can flow.Hence there is no heat produced(or no I*I*R losses)."
print " If we neglect friction,no force is required to pull the coil."
print "(d)The force required to pull the loop if it has no cut and has a resistance of 1 mill ohm is :"
print " For fig (a): F=%e N." %(F_a)
print " For fig (b): F=%e N." %(F_b)
```

In [17]:

```
#Question:
"""Finding the magnetic field due to a line caryying current."""
from math import pi
#Variable Declaration:
I=90.0 #Current flowing through the line(in Amperes)
x=1.5 #Distance of point of observation from the line(in metres)
#Calculations:
abs_per=(4*pi)/(1e07)
B=(abs_per*I)/(2*pi*x)
#Result:
print "The magnetic field due to the current at a point 1.5 m below the line is %e T." %(B)
print "By applying the right-hand thumb rule,we find that the direction of the magnetic field is from north to south."
```

In [18]:

```
#Question:
"""Finding the force per unit length on a current carrying wire."""
from math import sin,radians
#Variable Declaration:
I=8.0 #Current flowing through the wire(in Amperes)
B=0.15 #Magnitude of uniform magnetic field(in Tesla)
angle=30 #Angle between the direction of current and the uniform magnetic field(in degrees)
#Calculations:
Fu=I*B*sin(radians(angle))
#Result:
print "The force per unit length of the wire is %.2f N/m." %(Fu)
```

In [29]:

```
#Question:
"""Finding the torque experienced by a square coil."""
from math import sin,radians
#Variable Declaration:
I=12.0 #Current flowing through the square coil(in Amperes)
N=20.0 #Number of turns in the square coil
l=10e-02 #Length of each side of the square coil(in metres)
B=0.8 #Magnitude of uniform horizontal magnetic field(in Tesla)
angle=30.0 #Angle made by normal to the plane of the coil with the direction of horizontal magnetic field(in degrees)
#Calculations:
F=I*B*l*N
x=l*sin(radians(angle))
T=F*x
#Result:
print "The torque experienced by the coil is %.3f Nm." %(T)
```

In [31]:

```
#Question:
"""Finding the net force on a rectangular loop."""
from math import pi
#Variable Declaration:
I1=15.0 #Current carried by the rectangular loop(in Amperes)
I2=25.0 #Current carried by the straight conductor(in Amperes)
l=25e-02 #Length of the rectangular loop(in metres)
w=10e-02 #Width of the rectangular loop(in metres)
r=2e-02 #Separation between the nearer side of the loop and the conductor(in metres)
#Calculations:
abs_per=(4*pi)/(1e07)
"""Parts AD and BC do not experience any force,since these conductors are at right angles to the long straight conductor.
The current I1 in AB and the current I2 in the straight conductor are in the same direction.
Hence,the force F_AB is attractive."""
F_AB=((abs_per*I1*I2)/(2*pi*r))*l
""" The current I1 in CD and the current I2 in the straight conductor are in opposite directions.
Hence,the force F_CD is repulsive."""
F_CD=((abs_per*I1*I2)/(2*pi*(r+w)))*l
F_net=F_AB-F_CD
#Result:
print "The net force on the rectangular loop is %.5f mN." %(F_net*1000.0)
```

In [24]:

```
#Question:
"""Finding the location of a point where the resultant magnetic field is zero."""
from math import pi
#Variable Declaration:
I=10.0 #Current flowing through the wire(in Amperes)
B=2.0e-03 #Horizontal component of Earth's magnetic field(in Tesla)
#Calculations:
""" To make the resultant magnetic field zero,the magnetic filed produced by the long vertical wire must be equal and opposite
to the horizontal component of Earth's magnetic field.This is possible at a point P,west of the wire. """
abs_per=(4*pi)/(1e07)
x=(abs_per*I)/(2*pi*B)
#Result:
print "The distance between the required point from the wire is %e m,to the west of the wire." %(x)
```

In [22]:

```
#Question:
"""Finding the force per unit length between two current carrying wires."""
from math import pi
#Variable Declaration:
I=300.0 #Current flowing through each wire(in Amperes)
r=1.5e-02 #Separation between the wires(in metres)
l=70e-02 #Length of each wire(in metres)
#Calculations:
abs_per=(4*pi)/(1e07)
"""Since the length of the wires is 70 cm and their separation is only 1.5 cm(i.e, l>>r),
we can conclude that for the given separation the two wires are infinitely long. """
F=(abs_per*I*I)/(2*pi*r)
#Result:
print "The force per unit length between the two wires is %.2f N/m." %(F)
print "Since the currents in the two wires are in the opposite directions,the force between them will be repulsive."""
```

In [21]:

```
#Question:
"""Finding the counter torque to prevent a coil from turning."""
from math import pi,sin,radians
#Variable Declaration:
N=30.0 #Number of turns in the circular coil
r=8e-02 #Radius of circular coil(in metres)
I=6.0 #Current flowing through the circular coil(in Amperes)
B=1.0 #Magnitude of uniform magnetic field(in Tesla)
angle=60 #Angle made by the field lines with the normal to the coil(in degrees)
#Calculations:
"""The counter torque required to prevent the coil from moving must be equal(and opposite) to the torque developed."""
A=pi*r*r
tor=B*I*N*A*sin(radians(angle))
#Result:
print "The counter torque that must be applied to prevent the coil from turning is %.2f Nm." %(tor)
```

In [19]:

```
#Question:
"""Finding the maximum voltage induced in a coil."""
#Variable Declaration:
A=300e-04 #Area of circular coil(in square-m)
N=25.0 #Number of turns in the circular coil
w=40.0 #Angluar frequency(in radians per second)
B=0.05 #Magnitude of uniform magnetic field(in Tesla)
#Calculations:
Em=N*B*A*w
#Result:
print "The maximum value of emf induced in the coil is %.2f V." %(Em)
```

In [32]:

```
#Question:
"""Finding the induces emf in a circular conducting loop."""
from math import pi
#Variable Declaration:
B=0.02 #Magnitude of uniform magnetic field(in Tesla)
r=2e-02 #Radius of the circular loop(in metres)
rate=1.0e-03 #Rate of shrinking of the radius(in metre per second)
#Calculations:
""" flux=B*A; A=(pi*r*r);
e=d(flux)/dt;
e=(B*pi*2*r)*(dr/dt); """
e=B*pi*2*r*rate
#Result:
print "The emf induced in the loop at an instant when the radius is 2 cm is %e V." %(e)
```