##Ex:5.1
import math
v1=0.43;##volts
i1=2.5*10**-3;##in Amps.
v2=0.65;##volts
i2=7.4*10**-3;##in Amps.
r1=v1/i1;
r2=v2/i2;
print'%s %.2f %s'%("Diode resistance for 2.5A current = ",r1," ohms");
print'%s %.2f %s'%("\n Diode resistance for 0.65V = ",r2," ohms");
##Ex:5.2
import math
i=15.*10**-3;
R=(21.-2.2)/i;
v=18.8;##in volts
P=i*v*1000.;
print'%s %.2f %s %.2f %s '%("Resistor ",R," ohms" and " of ",P," mW");
##Ex:5.3
import math
I_c=30.;##in mA
I_b=0.6;
I_e=I_c+I_b;
hfe=I_c/I_b;
print'%s %.2f %s %.2f %s '%("Emitter current = ",I_e," ohms" and "hfe = ",hfe,"");
##Ex:5.4
import math
I_c=30.;##in mA
I_b=0.6;
I_e=I_c+I_b;
hfe=I_c/I_b;
print'%s %.2f %s %.2f %s '%("Emitter current = ",I_e," ohms" and "hfe = ",hfe,"");
##Ex:5.5
import math
I_e=98.;##in mA
I_c=97.;
I_b=I_e-I_c;
hfe=I_c/I_b;
print'%s %.2f %s %.2f %s '%("Emitter current = ",I_b," ohms" and "hfe = ",hfe,"");
##Ex:5.6
import math
I_c=1.5;##in A
I_b=50.*10**-3;
V_ce=6.;##volts
hfe=I_c/I_b;
P=I_c*V_ce;
print'%s %.2f %s'%("hfe required = ",hfe,"");
print'%s %.2f %s'%("\n collector power dissipation = ",P," W");
##Ex:5.7
import math
hfe=200.
I_c=10.*10**-3;
dI_b=I_c/hfe;
dI_c=hfe*dI_b/100.;
print'%s %.4f %s'%("Base current = ",dI_b," A ");
print'%s %.4f %s'%("\nChange in collector current = ",dI_c," mA");
##Ex:5.8
import math
dV_gs=0.025;
g_fs=-0.5;
dI_d=dV_gs*g_fs;##in mA
I_d1=50.*10**-3;##in mA
I_d2=dI_d+I_d1;
print'%s %.2f %s'%("Change in drain current = ",dI_d," A");
print'%s %.2f %s'%("\nNew value of drain current = ",I_d2," A");