##Ex:4.1
import math
V_m=20.;##in volts
f=50.;##in Hz
t1=2.5*10**-3;
t2=15.*10**-3;
V1=V_m*math.sin(2.*math.pi*f*t1);
V2=V_m*math.sin(2.*math.pi*f*t2);
print'%s %.2f %s'%("Voltage at 2.5ms = ",V1," V");
print'%s %.2f %s'%("\n Voltage at 15ms = ",V2," V");
##Ex:4.2
import math
f=400.;##in Hz
T=1./f;
print'%s %.2f %s %.4f %s '%("Time period of ",f," Hz" and " waveform = ",T," sec");
##Ex:4.3
import math
T=40.*10**-3;##in Hz
f=1./T;
print'%s %.2f %s'%("Frequency of 40 ms waveform = ",f," Hz");
##Ex:4.4
import math
V_rms=240.;##in Volts
V_pk=1.414*V_rms;
print'%s %.2f %s %.2f %s' %("Peak voltage of ",V_rms," V RMS" and " voltage = ",V_pk," V");
##Ex:4.5
import math
I_pk=50.*10**-3;##in Amps
I_rms=0.353*I_pk;
print'%s %.2f %s'%("RMS current of 50mA peak current = ",I_rms," A");
##Ex:4.6
import math
V=10.;##pk-pk voltage
r=1000.;##ohms
I_pk=V/r;##in Amps
I_rms=0.353*I_pk*1000.;##milliamps
print'%s %.2f %s'%("RMS current of 10V peak-peak voltage = ",I_rms," mA");
##Ex:4.7
import math
c=1.*10**-6;
f1=100.;
f2=10000.;
X_c1=1./(2.*math.pi*f1*c);
X_c2=1./(2.*math.pi*f2*c);
print'%s %.2f %s'%("Reactance at 100Hz = ",X_c1," mA");
print'%s %.2f %s'%("\n Reactance at 10kHz = ",X_c2," mA");
##Ex:4.8
import math
V=240.;
c=100.*10**-9;
f=50.;
X_c=1./(2.*math.pi*f*c);
I_c=V/X_c;
print'%s %.2f %s'%("Current flow = ",I_c," A");
##Ex:4.9
import math
L=1.*10**-3;
f1=100.;
f2=10000.;
X_L1=(2.*math.pi*f1*L);
X_L2=(2.*math.pi*f2*L);
print'%s %.2f %s'%("Reactance at 100Hz = ",X_L1," ohm");
print'%s %.2f %s'%("\nReactance at 10kHz = ",X_L2," ohm");
##Ex:4.10
import math
L=1.*10**-3;
f1=100.;
f2=10000.;
X_L1=(2.*math.pi*f1*L);
X_L2=(2.*math.pi*f2*L);
print'%s %.2f %s'%("Reactance at 100Hz = ",X_L1," ohm");
print'%s %.2f %s'%("\nReactance at 10kHz = ",X_L2," ohm");
##Ex:4.11
import math
C=2.*10**-6;
f=400.;
V=115.;
X_C=1./(2.*math.pi*f*C);
r=199.;
z=math.sqrt(r**2+X_C**2);
I_s=V/z;
print'%s %.2f %s'%("Reactance = ",X_C," ohm");
print'%s %.2f %s'%("\n Current = ",I_s," A");
##Ex:4.12
import math
L=150.*10**-3;
f=400.;
V=115.;
X_L=(2.*math.pi*f*L);
r=250.;
z=math.sqrt(r**2+X_L**2);
I_s=V/z;
print'%s %.2f %s'%("Reactance = ",X_L," ohm");
print'%s %.2f %s'%("\n Current = ",I_s," A")
##Ex:4.13
import math
L=100.*10**-3;
f=400.;
C=(1./(4.*math.pi*math.pi*f*f*L))*10**6;
print'%s %.2f %s'%("Capacitance required = ",C," uF");
##Ex:4.14
import math
L=20.*10**-3;
f=2000.;
V=1.5;
r=100.;
C=10.*10**-9;
X_L=(2.*math.pi*f*L);
X_C=1./(2.*math.pi*f*C);
z=math.sqrt(r**2+(X_L-X_C)**2);
i=V/z;
v=i*r;
print'%s %.4f %s'%("Current supplied = ",i," mA");
print'%s %.2f %s'%("\nVoltage developed = ",v," V");
##Ex:4.15
import math
N_s=120.;
V_p=220.;
N_p=2000.;
V_s=N_s*V_p/N_p;
print'%s %.2f %s'%("Secondry voltage = ",V_s," V");
##Ex:4.16
import math
V_p=200.;
V_s=10.;
N_p=1200.;
N_s=N_p*V_s/V_p;
i_s=2.5;
i_p=N_s*i_s/N_p;
print'%s %.2f %s'%("Secondry turns = ",N_s,"");
print'%s %.2f %s'%("\nprimary current = ",i_p,"A");