# conversion efficiency
import math
#Variable declaration
Vdc=9.0
Idc= 20*10**-3
V0=3.0
I0=12*10**-3
#Calculations
P0=V0*I0
Pdc=Vdc*Idc
eta=P0/Pdc
#Result
print("\nEfficiency(Eta) = %.0f%%"%(eta*100))
#calculation of different parameters of CC circuit
import math
#Variable declaration
Ib= 100* 10**-6
hie=2000.0
R=50*10**3
hfe=100.0
R4=2.1*10**3
Rl=1000.0
#Calculations
Vbe=Ib*hie
Ii=Vbe/R
I1=Ii+Ib
I0=hfe*Ib*R4/(R4+Rl)
Ai=I0/I1
V0=-I0*Rl
Av=V0/Vbe
#Result
print("Total Current Input, I = %.0f micro A"%(I1*10**6))
print("Current through Rl, I0 = %.2fmA"%(I0*1000))
print("Current amplification, Ai = %d"%Ai)
print("V0 = %.2f\nAv = %.1f"%(V0,Av))
print("\nNegative sign indicates that there is phase shift of 180°")
print("between input and output voltages,i.e. as base voltage goes more positive,(it is NPN transistor),")
print("the collector voltage goes more negative")
#calculation of different parameters of CE circuit
import math
#Variable declaration
hie=1000.0
hfe=99.0
#hre negligible
r2=60.0
r3=30.0
r4=5.0
r7=20.0
r6=30.0
Rl1=20000.0
#Calculations
R23=r2*r3/(r2+r3)
R47=r4*r7/(r4+r7)
Rl=R47
Av=-hfe*Rl*10/hie
Av=math.floor(Av)
Ri=Rl1*1000/(Rl1+1000)
#Calculations
print("Rl = %d kohm\nAv = %d\nRi = %.0f Ohm"%(Rl,Av*100,Ri))
#calculation of different parameters of CC circuit
import math
#Variable declaration
hic = 1100.0
hrc = 1.0
hfc = -51.0
hoc = 25.0*10**-6
Rl=10000.0
#Calculations
Rs=Rl
Ai=(-hfc)/(1.0+(hoc*Rl))
Ri=(hic+hrc*Ai*Rl)/1000
Av=Ai*Rl/Ri
Avs=Av*Ri/(Ri+Rs)
R0=1/(hoc-(hfc*hrc/(hic+Rs)))
#Result
print("Ai = %.1f\nRi = %.1f kOhm\nAv = %.3f\nAvs = %.3f\nR0 = %.0f ohm"%(Ai,Ri,Av,Avs,math.ceil(R0)))
#maximum value of RL in CE configuration
import math
#Variable declaration
hie = 1100.0
hfe = 50.0
hre = 2.50*10**-4
hoe = 25*10**-6
#Calculations
Rl=0.1*hie/((hfe*hre)-(0.1*hoe*hie))
Rl=Rl/1000
#Result
print("Rl= %.1f K Ohm"%Rl)
# voltage gains Avs Av1 and Av2 for given circuit
import math
#Variable declaration
hie =1000.0
hre = 10**-4
hfe = 50.0
hoe = 10**-8
Rl2=5000.0
Rs=1000.0
#Calculations
Ri2=hie+(1+hfe)*Rl2
Ri2=Ri2/1000
Av2=1-(hie/(Ri2*1000))
Rl1=(10.0*256)/(10+256.0)
Ai1=-50*hfe
Av1=-hfe*Rl1/hie
o_g=Av1*Av2
Avs=o_g*Rs/(Rs+hie)
#Result
print("Ri2 = %d KOhm"%Ri2)
print("Av2 = %.3f"%Av2)
print("Rl1 = %.2f KOhm\nAv1 = %.1f"%(Rl1,Av1*1000))
print("Overall Gain = %.0f\nAvs = %.0f"%(math.floor(o_g*1000),math.floor(Avs*1000)))