#Variable declaration
Rb=200 #base resistance(ohm)
Vbe=0.7 #base emitter voltage drop(V) in active region
Vbb=5 #base voltage of bipolar transistor(V)
beeta=100 #current gain
Rc=3 #collector resistance(k ohms)
Vcc=10 #voltage given to the collector(V)
#Calculations
Ib=(Vbb-Vbe)/Rb #base current(mA)
Ic=beeta*Ib #collector current(mA)
Vcb=-Vbe-(Rc*Ic)+Vcc #collector base voltage drop(V)
#Results
print"base current",Ib,"mA"
print"collector current",Ic,"mA"
print"reverse bias collector junction is",Vcb,"V"
#Variable declaration
Vbb=5 #base voltage of bipolar transistor(V)
Vbe=0.7 #base emitter voltage drop(V) in active region
Rb=150 #base resistance(ohm)
beeta=125 #curret gain
Rc=3 #collector resistance(k ohms)
Vcc=10 #supply voltage(V)
Vce=0.2 #collector to emitter voltage(V)
#Calculations
#Part a
Ib=(Vbb-Vbe)/Rb #base current(mA)
Ic=beeta*Ib #collector current(mA)
Vcb=-Vbe-(Rc*Ic)+Vcc #collector base voltage drop(V)
#Part b -for npn transistor
Vbe=0.8 #base emitter voltage drop(V) in saturation
Ic=(Vcc-Vce)/Rc #collector current(mA)
Ib=(Vbb-Vbe)/Rb #base current(mA)
Ibmin=Ic/beeta #minimum base current(mA) to go into saturation(mA)
#Results
print"In active region, base current is",round(Ib/1E-3),"*10**-3 mA and collector current is",round(Ic,2),"mA"
print"base current and collector current in npn are",round((Ib/1E-3),2),"*10**-3 mA","and",round(Ic,2),"mA resp."
print"base current minimum is",round(Ibmin,3),"mA"
#Variable declaration
Vbb=5 #base voltage of bipolar transistor(V)
Vbe=0.7 #base emitter voltage drop(V) in active region
Rb=50 #base resistance(ohm)
beeta=50 #current gain
Re=1.8 #emitter resistance(k ohms)
Vcc=10 #supply voltage(V)
Vce=0.2 #collector to emitter voltage(V)
#Calculations
Ib=(Vbb-Vbe)/(Rb+Re*(beeta+1)) #base current(mA)
Ic=beeta*Ib #collector current(mA)
Ie=Ib+Ic #emitter current(mA)
#Results
print"values are Ib:",round(Ib,2),"mA,Ic:",round(Ic,2),"mA and Ie:",round(Ie,2),"mA"
#Variable declaration
Vbe=0.7 #base to emitter voltage(V)
Rb=250 #base resistance(k ohms)
Vcc=10 #supply voltage(V)
Rl=0.5 #load resistance(k ohms)
#Calculations
Ic=Vcc/Rl #collector current(mA)
IbQ=(Vcc-Vbe)/Rb #Ib at operating point(uA)
IcQ=8 #Ic at operating point(mA)
VceQ=6 #Vce at operating point(V)
#Results
print"values are IbQ:",IbQ,"uA,IcQ:",IcQ,"mA and Vcc:",Vcc,"V"
print"collector current Ic is",Ic,"mA and output voltage,vL=6-2 sinwt V"
#Variable declaration
Vgs=12 #gate to source voltage(V)
Vt=4 #threshold voltage(V)
Id=12.8 #drain current(mA)
K=0.0002 #device parameter
Vdd=24 #drain voltage(V)
Vds=Vgs=8 #drain to source voltage(V)
#Calculations
Id=K*((Vds-Vt)**2) #drain current at Vds=8V
Rd=(Vdd-Vds)/Id #drain resistance(k ohms)
#Result
print"diode resistance is",Rd,"ohms"
#Variable declaration
Vds=7.5 #drain to source voltage(V)
Id=5 #drain current(mA)
#Calculations
Vgs=-1.5 #gate to source voltage(V)
Vgg=-Vgs #gate voltage=gate to source voltage(V)
#Result
print"gate voltage is",Vgg,"V"
#Variable declaration
Vds=7.5 #drain to source voltage(V)
Idss=8. #drain current for Vgs(V)
Vgs=2. #gate to source voltage(V)
Vp=4. #peak voltage(V)
#Calculations
Id=Idss*((Vp-Vgs)/Vp)**2 #drain current(mA)
#Result
print"diode current is",Id,"mA"
#Variable declaration
beeta=160 #current gain
Vee=10 #emitter voltage(V)
Rb=400 #base resistance(k ohms)
Veb=0.8 #emitter to base voltage(V)
Re=2.5 #emitter resistance(k ohms)
Rc=1.5 #collector resistance(k ohms)
#Calculations
#Part a
Ib=(Vee-Veb)/((Re*(1+beeta))+Rb) #base current(uA)
Ic=beeta*Ib #collector current(mA)
Ie=(beeta+1)*Ib #emitter current(mA)
Vce=Vee-(Re*Ie)-(Rc*Ic) #emitter to collector voltage(V)
Vce=-Vce #collector to emitter voltage(V)
#Part b
beeta=80 #current gain
Ib1=(Vee-Veb)/((Re*(1+beeta))+Rb) #base current(uA)
Ic1=beeta*Ib1 #collector current(mA)
Ie1=(beeta+1)*Ib1 #emitter current(mA)
Vce1=-(Vee-(Ie1*Re)-(Rc*Ic1)) #collector to emitter voltage(V)
#Result
print"collector current and Vce for beeta=160 are",round(Ic,2),"mA","and",round(Vce,2),"V"
print"Ic and Vce for beeta=80 are",round(Ic,2),"mA","and",round(Vce1,2),"V"
from sympy import*
import math
#Variable declaration
K=2 #device parameter
Rd=Rs=2.5*10**3 #drain resistance(k ohms)
R1=100*10**3 #resistance(ohms)
R2=200*10**3 #resistance(ohms)
Vdd=12 #drain voltage(V)
Vt=4 #threshold voltage(V)
#Calculations
Vgg=(R2*Vdd)/(R1+R2)
Id=symbols('Id') #gate voltage(V)
expr=solve(Id**2-3.28*Id+2.56,Id)
print expr
Id=1.28
Vds=Vdd-5*Id
#Result
print"Id is",Id,"mA and Vds is",Vds,"V"
#Variable declaration
k=2. #device parameter
Vt=-1. #threshold voltage(V)
Vdd=-12. #drain voltage(V)
R1=300. #resistance(kohms)
R2=100. #resistance(kohms)
#Calculations
#Part a
Vgs=-2 #gate to source voltage(V)
Vgg=(R2*Vdd)/(R1+R2) #gate voltage(V)
Id=k*((Vgs-Vt)**2) #drain current(mA)
Rs=(Vgs-Vgg)/Id #source resistance(k ohms) as Id=Is,Kvl in GS loop
Is=Id
#Part b
Vds=-4 #drain to source voltage(V)
Rd=(-Vdd+Vds-(Is*Rs))/Id #applying kvl in DS loop
#Part c
Vt=-1.5 #threshold voltage(V)
Vgg=-1.5 #gate voltage using Id formula
R2new=(Vgg*R1)/(Vdd-Vgg) #new resistance(k ohms)
#Results
print"a)source resistance is",Rs,"kohm"
print"b)drain resistance is",Rd,"kohm"
print"c)R2new is",round(R2new,2),"kohm"
import math
#Variable declaration
Vp=-4 #peak voltage(V)
Idss=10 #drain current for Vgs(V)
Vdd=18 #drain voltage(V)
Rs=2 #source resistance(ohms)
Rd=2 #drain resistance(ohms)
R1=450*10**3 #resistance(ohms)
R2=90*10**3 #resistance(ohms)
#Calculations
Vgg=(R2*Vdd)/(R1+R2)
from sympy import*
Id=symbols('Id')
expr=solve(20*Id**2-148*Id+245,Id)
print expr
Id1=2.5
Vds=Vdd-((Rs+Rd)*Id1)
#Result
print"Id is",Id1,"mA and Vds is",Vds,"V"
import math
#Variable declaration
Vp=4 #peak voltage(V)
Idss=12. #drain current for Vgs(V)
Vdd=12 #drain voltage(V)
Id=4. #drain current(mA)
Vds=6 #drain to source voltage(V)
#Calculations
Rs=(Vp/4)*(1-(math.sqrt(Id/Idss))) #by Id=Idss(1-(Vgs/Vp))^2 and putting Vgs=4Rs in it and solving
Rd=((Vdd+Vds)/Id)-Rs #solving equation -Vdd-Vds+(Id*(Rd+Rs))=0
#Result
print"source resistance is",round(Rs,2),"kohm"
print"drain resistance",round(Rd,2),"kohms"