# efficiency
import math
#Variable declaration
Pac=0.1 #in W
Vcc=20.0 #in V
Ic=20.0 #in mA
#Calculations
Pdc=Vcc*Ic*10**-3 #in W
eta=(Pac/Pdc)*100 #efficiency
#Result
print("efficiency is ,(%%)= %.f"%eta)
# collector current
import math
#Variable declaration
Pac=2.0 #in W
Vcc=12.0 #in V
#Calculations
Ic=(Pac*math.sqrt(2)*math.sqrt(2))/Vcc
#Result
print("maximum collector current is ,(A)= %.2f" %Ic)
# collector efficiency and power rating
import math
#Variable declaration
Pac=3.0 #in W
Pdc=10.0 #in W
#Calculations
eta=(Pac/Pdc)*100 #percentage efficieny
#Result
print("collector efficiency is , (%%) = %.f"%eta)
print("power rating of transistor is ,(W) = %.f" %Pdc)
# power
import math
#Variable declaration
dIc=100.0 #in mA
Rl=6.0 #in ohm
Rl=6.0 #in ohm
dVc=10.0 #in V
#Calculations
mv=dIc*Rl*10**-3 #in V
pd=mv*dIc #in mW
oi=(dVc/dIc)*10**3 #in ohm
n=math.sqrt(oi/Rl) #turn ratio of transformer
tsv=dVc/n #om V
Il=tsv/Rl #in A
ptr= Il**2*Rl*10**3 #in mW
#Result
print("(i) power developed in loudspeaker is , (mW)= %.f"%pd)
print("(ii) power transferred to loudspeaker is ,(mw)= %.f"%ptr)
#in textbook in second case there is one point deviation in the answer.
# power
import math
#Variable declaration
n=10.0 #turn ratio
Rl=10.0 #ohm
Ic=100.0 #in mA
#Result
Rld=n**2*Rl #in ohm
Irms=Ic/(math.sqrt(2)) #in mA
P=Irms**2*Rld #in W
#Result
print("maximum power output is ,(W)= %.f"%(P*10**-6))
# harmonic distortions and change in power
import math
#Variable declaration
#ie=15*sin 400*t+1.5*sin 800*t + 1.2*sin 1200*t + 0.5*sin 1600*t given equation
I2=1.5 #in A
I1=15.0 #in A
I3=1.2 #in A
I4=0.5 #in A
D2=(I2/I1)*100 #Second percentage harmonic distortion
D3=(I3/I1)*100 #Third percentage harmonic distortion
#in book I2 is mentioned wrongly in place of I1
D4=(I4/I1)*100 #Fourth percentage harmonic distortion
D=math.sqrt(D2**2+D3**2+D4**2)/100 #Distortion Factor
P1=1.0 #assume
P=(1+D**2)*P1 #in W
peri=((P-P1)/P1)*100 #percentage increase in power due to distortion
#Result
print("part (i)")
print("Second percentage harmonic distortion (D2) is ,(%%) = %.f"%D2)
print("Third percentage harmonic distortion (D3) is ,(%%) = %.f"%D3)
print("Fourth percentage harmonic distortion (D4) is ,(%%) = %.2f"%D4)
print("\npart (ii)")
print("percentage increase in power due to distortion is ,(%%) = %.2f"%peri)
# answer for % increase is slightly different than book
# power dissipated
import math
#Variable declaration
Vcc=15.0 #in V
Vpeak=24.0/2 #in V
Rl=100.0 #in ohm
#Calculations
Ipeak= Vpeak/Rl #in A
Pdc=Vcc*(2/(math.pi))*Ipeak #in W
pad=(1.0/2)*(Vpeak**2)/Rl #in W
pd=Pdc-pad #in W
pde=pd/2 #in W
#Result
print("power dissipated by each transistor is,(mW)= %.f"%(pde*10**3))