#Example 20_1
import math
#To findout the time that it has to wait after turning off the set before it is safe to touch capacitor
r=10.0**6 #Units in Ohms
c=10.0**-5 #Units in F
ti=r*c #Units in Sec
print "We have to wait for a time of t=",round(ti)," sec"
#Example 20_2
import math
#To find the rms current in the circuit
f=20 #Units in Hz
c=4*10.0**-7 #Units in F
xc=1/(2.0*math.pi*f*c) #Units in Ohms/sec
f=2*10**6 #Units in Hz
xc1=1/(2*math.pi*f*c) #Units in Ohms/sec
v=80.0 #Units in V
i=v/xc #Units in A
i1=v/xc1 #Units in A
print "The RMS current when f=20 Hz is=",round(i,5)," Ohms\nThe RMS current when f=2*10**6 Hz is=",round(i1,2)," Ohms"
#Example 20_3
import math
#To find the current through the inductor
f=60 #Units in Hz
l=15.0*10**-3 #Units in H
xl=2*math.pi*f*l #Units in Ohms
v=40 #Units in V
i=v/xl #Units in A
print "The current in the inductor when frequency=60 Hz is I=",round(i,2)," A"
f=6.0*10**5 #Units in Hz
l=15.0*10**-3 #Units in H
xl=2*math.pi*f*l #Units in Ohms
v=40 #Units in V
i=v/xl #Units in A
print "\nThe current in the inductor when frequency=6*10**2 Hz is I=",round(i,6)," A"
#Example 20_4
import math
#To find current in circuit, Voltmeter reading, reading across capacitor and power loss
f=2000 #Units in Hz
c=0.6*10**-6 #Units in F
xc=1/(2*math.pi*f*c) #Units in Ohms
r=300 #Units in Ohms
z=math.sqrt(r**2+xc**2) #Units in Ohms
v=80 #Units in V
i=v/z #Units in A
vr=i*r #Units in V
vc=i*xc #Units in V
p=i**2*r #Units in W
print "The current in circuit is I=",round(i,4)," A\nVolt meter readings across resistor Vr=",round(vr,1)," V\nReadings across capacitor is Vc=",round(vc,1)," V\nPower loss in circuit is=",round(p,1)," W"
#Example 20_5
import math
#To find the current in circuit and voltmeters reading across R C and L
f=600 #Units in Hz
l=4.0*10**-3 #Units in H
xl=2*math.pi*f*l #Units in Ohms
c=10.0*10**-6 #Units in F
xc=1/(2*math.pi*f*c) #Units in Ohms
r=20.0 #Units in Ohms
z=math.sqrt(r**2+(xl-xc)**2) #Units in Ohms
v=50.0 #Units in V
i=v/z #Units in A
vr=i*r #Units in V
vl=i*xl #Units in V
vc=i*xc #Units in V
print "The current in circuit is I=",round(i,2)," A\nVolt meter reading across R Vr=",round(vr,1)," V\nVolt meter reading across L Vl=",round(vl,1)," V\nVolt meter reading across c Vc=",round(vc,1)," V\n"