In [1]:

```
import math #Example15_1
#To find the value of q and how many electrons must be removed and fraction of atoms lost
dist=2 #Units in meters
f=0.0294 #Units in N
s=9*10**9 #Units in N meter**2/C**2
q=math.sqrt((dist**2*f)/s) #Units in C
print "The value of q is=",round(q,8)," C\n"
charge=3.61*10**-6 #Units in C
c_elec=1.6*10**-19 #Units in C
n=charge/c_elec #Units in number
print "Number of electrons to be removed is="
print n
f1=3*10.0**22 #Units in number
fraction=n/f1 #Units of number
print "Fraction of atoms lost is="
print fraction
```

In [2]:

```
import math #Example15_2
#To find the force on the center charge
k=9*10**9 #Units in N meter**2/C**2
q1=4*10.0**-6 #Units in C
q2=5*10.0**-6 #Units in C
r1=2 #Units in meters
r2=4 #Units in meters
q3=6*10.0**-6 #Units in C
f1=(k*q1*q2)/r1**2 #Units in N
f2=(k*q2*q3)/r2**2 #Units in N
f=f1-f2 #Units in C
print "The force on the center charge is=",round(f,5)," N"
```

In [3]:

```
import math #Example15_3
#To find the resultant force
f1=6 #Units in N
f2=18 #Units in N
f=math.sqrt(f1**2+f2**2) #Units in N
theta=math.atan(f2/f1)*180/math.pi #Units in degrees
print "The resultant force is f=",round(f)," N \nThe resultant angle is theta=",round(theta,1)," degrees"
#In text book answer printed wrong as f=19 N correct answer is f=18N
```

In [4]:

```
import math #Example15_4
#To find the resultant force on 20 micro C
f1=2 #Units in N
f2=1.8 #Units in N
theta=37.0 #Units in degrees
f2x=f2*math.cos(theta*math.pi/180) #Units in N
f2y=f2*math.sin(theta*math.pi/180) #Units in N
fy=f1+f2y #Units in N
f=math.sqrt(fy**2+f2x**2) #Units in N
theta=math.atan(fy/f2x)*180/math.pi #Units in degrees
print "The resultant force is f=",round(f,1)," N \n The resultant angle is theta=",round(theta,1)," degrees"
```

In [5]:

```
import math #Example15_6
#To find the magnitude of E
k=9*10**9 #Units in N meter**2/C**2
q=3.6*10**-6 #Units in C
theta=37 #Units in degrees
r=10*math.sin(theta*math.pi/180)*10**-2 #Units in meters
e1=(k*q)/r**2 #Units in N/C
q2=5*10**-6 #Units in C
theta=37 #Units in degrees
r1=10*10**-2 #Units in meters
e2=(k*q2)/r1**2 #Units in N/C
e1y=e1 #Units in N/C
e2x=e2*math.cos(theta*math.pi/180) #Units in N/C
e2y=-e2*math.sin(theta*math.pi/180) #Units in N/C
ex=e2x #Units in N/C
ey=e1y+e2y #Units in N/C
e=math.sqrt(ex**2+ey**2) #Units in N/C
print "The magnitude of E is="
print round(e,2)
print "N/C"
#In text book the answer isprinted wrong as E=7.26*10**6 N/C but the correct answer is E=7198876.9 N/C
```

In [6]:

```
import math #Example15_7
#To find out how much charge occurs
e=3*10.0**6 #Units in N/C
r=0.050 #Units in meters
k=9*10.0**9 #Units in N meter**2/C**2
q=(e*r**2)/k #Units in C
print "The charge occured is q=",round(q,9)," C"
```

In [7]:

```
import math #Example15_8
#To show using lines of force that a charge suspended with in cavity induces an equal and opposite charge on surface
print "Lines of force come out of positive charge q suspended in cavity.\nCavity \nsurface must possess a negative charge since lines of force go and terminate on q.\nTherefore a charge +q must exist on outer portions."
```

In [8]:

```
import math #Example15_9
#To find the speed just before the field strikes
e=6000 #Units in N/C
q=1.6*10**-19 #Units in C
f=e*q #Units in N
m=1.67*10**-27 #Units in Kg
a=f/m #Units in meters/sec**2
vo=0 #Units in meters/sec
x=2*10**-3 #Units in meters
v=math.sqrt(vo**2+(2*a*x)) #Units in meters/sec
print "The field goes by a speed of ",round(v)," meters/sec"
#In text book answer printed wrong as v=48000 meters/sec the correct answer is v=47952 meters/sec
```