Chapter 18 : Direct current circuits

Example 18.1 Page No: 597

In [1]:
from __future__ import division
R1=2
R2=4
R3=5
R4=7
R_eq=R1+R2+R3+R4
v=6#in v
print "Solution a"
print "Equivalent resistance = %0.2f ohm"%R_eq
print "Solution b"
I=v/R_eq
print "Current = %0.2f Amps"%I
Solution a
Equivalent resistance = 18.00 ohm
Solution b
Current = 0.33 Amps

Example18.2 Page No: 599

In [2]:
delta_V=18#in volt
R1=3#in ohm
R2=6#in ohm
R3=9#in ohm
I1=delta_V/R1
I2=delta_V/R2
I3=delta_V/R3
print "solution a"
print "Current = %0.2f amps"%I1
print "Current = %0.2f amps"%I2
print "Current = %0.2f amps"%I3
P1=(I1**2)*R1
P2=(I2**2)*R2
P3=(I3**2)*R3
print "solution B"
print "Power = %0.2f watt"%P1
print "Power = %0.2f watt"%P2
print "Power = %0.2f watt"%P3
solution a
Current = 6.00 amps
Current = 3.00 amps
Current = 2.00 amps
solution B
Power = 108.00 watt
Power = 54.00 watt
Power = 36.00 watt

Example 18.3 Page No: 602

In [3]:
delta_Vac=42#in volt
R_eq=14#in ohm
I=delta_Vac/R_eq
print "solution b"
print "Current = %0.2f amps"%I
solution b
Current = 3.00 amps

Example 18.4 Page No: 605

In [11]:
from numpy import mat
#formula used x=inv(a)*b
I=mat([[1 ,-1, -1],[-4, 0 ,-9],[0, -5, 9]])
V=mat([[0],[6],[0]])
X=(I**-1)
a=X*V

print "Current value I1 = %0.2f, I2 = %0.2f & I3 = %0.2f amps"%(a[0],a[1],a[2])
Current value I1 = -0.83, I2 = -0.53 & I3 = -0.30 amps

Example 18.5 Page No: 606

In [14]:
from numpy import mat
#prob
#formula used x=inv(a)*b
I=mat([[8, 2, 0],[-3, 2, 0],[1, 1, -1]])
V=mat([[10],[-12],[0]])
X=I**-1
a=X*V

print "Current value I1 = %0.2f, I2 = %0.2f & I3 = %0.2f amps"%(a[0],a[1],a[2])
Current value I1 = 2.00, I2 = -3.00 & I3 = -1.00 amps

Example 18.6 Page No: 609

In [4]:
R=8*10**5#in ohms
C=5*10**-6#in Farad
t=R*C
print "Constant of the circuit = %0.2f s"%t

Q=C*12
print "Charge = %0.2e columb"%Q
q=0.632*Q
print "Charge = %0.2e columb when capacitance 63.2%%"%q
Constant of the circuit = 4.00 s
Charge = 6.00e-05 columb
Charge = 3.79e-05 columb when capacitance 63.2%

Example 18.7 Page No: 610

In [5]:
from math import log
x=log(4)
print "time = %0.2f s "%x
time = 1.39 s