##Ex2_1
import math
Q = 2*10**-6;
V = 10.
print'%s %.2e %s'%("Q = ",Q,"C")## charge
print'%s %.2f %s'%("V = ",V,"V") ##voltage
print'%s %.2e %s'%("C = Q/V = ",Q/V,"F")##calculation for capacitance
##Ex2_2
import math
C = 10**-6
V = 10.
print'%s %.2e %s'%("C =",(C),"F")##capacitance
print'%s %.2f %s'%("V = ",(V),"V")##voltage
print'%s %.2e %s'%("Q = C*V = ",(C*V),"C")##calculation for charge
#conveted in units
##Ex2_3
import math
Q = 5.*(10**-12) ;
V = 50.
print'%s %.2e %s'%("Q = ",(Q),"C")##charge
print'%s %.7f %s'%("V = ",(V),"V")##voltage
print'%s %.2e %s'%("C = Q/V = ",(Q/V),"F")##calculation for capacitance
#conveted into units
##Ex2_4
import math
I = 10.*(10**-6)
t= 10.
print'%s %.2e %s'%("I = ",(I),"A")##current
print'%s %.2f %s'%("t = ",(t),"seconds")##time
print'%s %.1e %s'%("Q =",(I*t),"* C ")##calculation for charge
#converted into units
##Ex2_5
import math
C = 2.*math.pow(10,-6)
t= 2.
I = 10.*math.pow(10,-6)
Q = I*t
print'%s %.2e %s'%("C = ",(C),"F")##capacitance
print'%s %.2f %s'%("t = ",(t),"seconds")##time
print'%s %.2e %s'%("I = ",(I),"A")##current
print'%s %.2e %s'%("Q = I*t = ",(Q),"C")##calculation for charge
print'%s %.2f %s'%("V = Q/C = ",(Q/C),"V")##calculation for voltage
##Ex2_6
import math
C = 12* 10** -6
f = 1.0*10**3
Xc = 1./(2.*math.pi*f*C)
print'%s %.2e %s'%("C = ",(C),"F")##capacitance
print'%s %.2f %s'%("at... f = ",(f),"Hz")##frequency
print'%s %.2f %s'%("Xc = 1/(2*pi*f*C) = ",(1./(2.*math.pi*f*C)),"ohm")##calculation for capacitive reactance
##Ex2_7
import math
C = 0.2*10**-6
f1 = 1.0*10**3
f2 = 50.
print'%s %.2e %s'%("C = ",(C),"F")##capacitance
print'%s %.2f %s'%("at... f = ",(f1),"Hz")##frequency
print'%s %.2f %s'%("Xc = 1/(2*pi*f*C) = ",(1./(2.*math.pi*f1*C)),"ohm")##calculation for capacitive reactance
print'%s %.2f %s'%("at... f = ",(f2),"Hz")##frequency
print'%s %.2f %s'%("Xc = 1/(2*pi*f*C) = ",(1./(2.*math.pi*f2*C)),"ohm")##calculation for capacitive reactance
##Ex2_8
import math
C1 = 0.5*10**-6
C2 = 0.5*10**-6
CT = (C1*C2)/(C1+C2)
print'%s %.2e %s'%("C1 = ",(C1),"F")##capacitance 1
print'%s %.2e %s'%("C1 = ",(C1),"F")##capacitance 2
print'%s %.2e %s'%("1/CT = 1/C1 + 1/C2 = (C1*C2)/(C1+C2) = ",(C1*C2/(C1+C2)),"F")##series capacitance
## proper ans. = 0.25*10^-6F
##Ex2_9
import math
C1 = 0.2*10**-12
C2 = 0.6*10**-12
C3 = 1.0*10**-12
print'%s %.2e %s'%("C1 = ",(C1),"F")##capacitance
print'%s %.2e %s'%("C2 = ",(C2),"F")##capacitance
print'%s %.2e %s'%("C3 = ",(C3),"F")##capacitance
print'%s %.2e %s'%("CT = C1+C2+C3 = ",(C1+C2+C3),"F")##parallel capacitance
##Ex2_10
import math
C = 10.*10**-6
V = 100.
W = C*(V**2)/2.
print'%s %.2e %s'%("C = ",(C),"F")##capacitance
print'%s %.2e %s'%("V = ",(V),"V")##voltage
print'%s %.2f %s'%("W = C*(V^2)/2 = ",(W),"Joules")##calculating for energy stored
##Ex2_11
import math
C = 10.*10**-6
delta_V = 100.
delta_t = 10.
ic = C*delta_V/delta_t
print'%s %.2e %s'%("C = ",(C),"F")##capacitance
print'%s %.2f %s'%("delta_V = ",(delta_V),"V")##change in voltage
print'%s %.2f %s'%("delta_t = ",(delta_t),"sec")##change in time
print'%s %.2e %s'%("ic = C*(delta delta_V/delta_t) = ",(ic),"A")##calculation for instantaneous current
#conveted into units
##Ex2_12
import math
Ii = 10
If = 15
delta_t = 2
dI = Ii - If
print'%s %.2f %s'%("Ii = ",(Ii),"A")##initial current
print'%s %.2f %s'%("If = ",(If),"A")##final current
print'%s %.2f %s'%("delta_t = ",(delta_t),"sec")##time taken to change current
print'%s %.2f %s'%("dI/dt = ",(abs(dI)/delta_t),"Amp/sec.")##calculation for rate of change of current
##wronge answer given in the textbook i.e. 0.5 Amp/sec.
##Ex2_13
import math
r = 5.0##rate of current change
vL = 50.##induced voltage
L = vL/(r)
print'%s %.2f %s'%("diL/dt = ",(r),"A/s")##rate of current change
print'%s %.2f %s'%("vL = ",(vL),"V")
print("vL = L*(diL/dt)")
print'%s %.2f %s'%("L = vL/(diL/dt) = ",(L)," Henry")##calculation for inductane
##Ex2_14
import math
I = 5.
L = 5.
WL = L*(I**2)/2.
print'%s %.2f %s'%("I = ",(I),"A")##current flow
print'%s %.2f %s'%("L = ",(L),"H")##inductance
print'%s %.2f %s'%("WL= ",(WL),"joules")##energy stored
##Ex2_15
import math
flux1 = 100.*10**-6
flux2 = 50.*10**-6
flux12 = flux1 - flux2
print'%s %.2e %s'%("flux1 = ",(flux1),"Wb")##flux of coil 1
print'%s %.2e %s'%("flux2 = ",(flux2),"Wb")##flux of coil 2
print("K = flux linkage between coil 1 and coil 2/flux of coil 1")##coefficient of coupling
print'%s %.2f %s'%("total = ",(flux12/flux1),"")
##Ex2_16
import math
L1 = 100.*10**-3
L2 = 50.*10**-3
K = 0.3
M = K*(L1*L2)**0.5
print'%s %.2f %s'%("L1 = ",(L1),"H")##inductance of coil 1
print'%s %.2f %s'%("L2 = ",(L2),"H")##inductance of coil 2
print'%s %.2f %s'%("K = ",(K),"")##coefficient of coupling
print("M = K*(L1*L2)^0.5")
print'%s %.2f %s'%("M = ",(M),"H")##mutual inductance
#converted into units
##Ex2_17
import math
L1 = 10.
L2 = 15.
LT = L1 + L2
print'%s %.2f %s'%("L1 = ",(L1),"H")##inductance of coil 1
print'%s %.2f %s'%("L2 = ",(L2),"H")##inductance of coil 2
print'%s %.2f %s'%("LT = L1+L2 = ",(LT),"mH")##series inductance
##Ex2_18
import math
L1 = 1.
L2 = 5.
LT = (L1*L2)/(L1+L2)
print'%s %.2f %s'%("L1 = ",(L1),"H")##inductance of coil 1
print'%s %.2f %s'%("L2 = ",(L2),"H")##inductance of coil 2
print("1/LT = 1/L1 + 1/L2")
print'%s %.2f %s'%("LT = (L1*L2)/(L1+L2) = ",(LT),"mH")##parallel inductance
##Ex2_19
import math
VNL = 50.
VL = 40.
IL = 4.
Rs = (VNL - VL)/IL
print'%s %.2f %s'%("VNL = ",(VNL),"V")##no load voltage
print'%s %.2f %s'%("VL = ",(VL),"V")##load voltage
print'%s %.2f %s'%("IL = ",(IL),"A")##load current
print'%s %.2f %s'%("Rs = (VNL - VL)/IL = ",(Rs),"ohm")##source resistane
##Ex2_20
import math
V = 2.5
print'%s %.2f %s'%("V1 = V2 = V3 = V4 = ",(V),"V")##four batteries of equal voltage connected in series
print'%s %.2f %s'%("VT = V1+V2+V3+V4 = ",(V+V+V+V),"V")##resultant voltage(series voltage)
##Ex2_20
import math
V = 2.
print'%s %.2f %s'%("V1 = V2 = V3 = V4 = ",(V),"V")##four batteries of equal voltage connected in series
print'%s %.2f %s'%("VT = V1 = V2 = V3 = V4 = ",(V),"V")##parallel voltage
##Ex2_22
import math
##considering the fig. 2.17 given in the question
R1 = 1.
R2 = 3.
R3 = 2.
V = 20.
print'%s %.2f %s'%("R1 =",(R1),"ohm")##value of resitance R1
print'%s %.2f %s'%("R2 =",(R2),"ohm")##value of resitance R2
print'%s %.2f %s'%("R3 =",(R3),"ohm")##value of resitance R3(across A and B terminals,
##across which thevenin equivalate circuit is need to determine)
print'%s %.2f %s'%("V =",(V),"V")##value of D.C. voltage applied
##TO FIND THEVENIN'S RESISTANCE (RTH),..
##CONSIDERING FIG 2.17
## WE REMOVE THE RESISTANCE (R1) ACROSS LOAD TERMINAL AB I.E.
##AND ALSO WE SHORT THE VOLTAGE SOURCE
##NOW ACCORDING TO MODIFIED CIRCUIT
print'%s %.2f %s'%("1/RTH = 1/R3 + 1/R2 = ",(1/((1/R3)+(1/R2))),"ohm")##R1 and R2 are in parallel
##TO FIND THEVENIN VOLTAGE (VTH),..
##CONSIDERING FIG 2.17
##WE DISCONNECT LOAD RESISTANCE (R1) AND MADE TERMINAL AB OPEN CIRCUIT
##ACCORDING TO MODIFIED CIRCUIT
##applying KVL in the loop, to find the amount of current flowing in circuit
##taking current as 'I' amperes
print("V = (R3*I)+(R2*I)")
I = V/(R2+R3)
print'%s %.2f %s'%("or, I = V/(R2+R3) = ",(I),"amperes")
##Voltage drop across R2 resistance = Thevenin voltage
##thus, voltage across AB i.e., thevenin voltage, is given as
print'%s %.2f %s'%("VTH = R2*I = ",(R2*I),"V")
## NOTE : Notations used in the program are as mentioned in the main fig. 2.17