#Calculate frequency and impedance and current and voltage across each element at resonance
#given
import math
R=12.;#ohm
L=200.*10.**-6.;#H
C=300.*10.**-12.;#F
Vs=9.;#V
fo=1./(2.*math.pi*math.sqrt(L*C));
Z=R;#impedance
print '%s %.1f %s' %("The Resonant frequency =",fo/1000,"kHz\n");
print '%s %.f %s' %("The impedance Z =",Z,"ohm\n");
Io=Vs/R;
print '%s %.2f %s' %("The Source current =",Io,"A\n");
Vl=Io*(2.*math.pi*fo*L);
Vc=Io/(2.*math.pi*fo*C);
Vr=Io*R;
print '%s %.1f %s' %("The voltage across the inductor =",Vl,"V\n");
print '%s %.1f %s' %("The voltage across the capacitor =",Vc,"V\n");
print '%s %.f %s' %("The voltage across the resistor =",Vr,"V\n");
#There is a slight variation in voltage across capacitor due to the approaximation
#Calculate frequency and impedance and current at resonance and current in coil and capacitor
#given
import math
R=10.;#ohm
L=100.*10.**-6.;#H
C=100.*10.**-12.;#F
Vs=10.;#V
fo=1./(2.*math.pi*math.sqrt(L*C));
Zp=L/(C*R); #impedance
print '%s %.3f %s' %("The Resonant frequency =",fo/10**6,"MHz\n");
print '%s %.f %s' %("The impedance Z =",Zp/1000,"kohm\n");
Io=Vs/Zp;
print '%s %.f %s' %("The Source current =",Io*10**6,"uA\n");
Xl=(2.*math.pi*fo*L);
Xc=1./(2.*math.pi*fo*C);
Z1=math.sqrt(Xl**2.+R**2.);
Z2=Xc;
Ic=Vs/Z2;
Il=Ic;
print '%s %.f %s' %("The current in the coil =",1000,"ohm\n");
print '%s %.f %s' %("The current in the capacitor =",Ic*1000,"mA\n");
#Calculate impedance and quality factor and bandwidth
#given
import math
R=10.;#ohm
L=150.*10.**-6.;#H
C=100.*10.**-12.;#F
fo=1/(2.*math.pi*math.sqrt(L*C));
Zp=L/(C*R); #impedance
print '%s %.f %s' %("The impedance Z =",Zp/1000,"kohm\n");
Xl=(2.*math.pi*fo*L);
Q=Xl/R;
BW=fo/Q;
print '%s %.1f %s' %("The Quality factor of the circuit =",Q,"\n");
print '%s %.1f %s' %("The Band width of the circuit =",BW/1000,"kHz\n");