In [3]:

```
from math import sqrt, pi
from __future__ import division
print "Refer to the circuit diagram shown in figure-3.7"
Rf=75 # diode forward resistance
Rl=10e3 # load resistance
Rs=10 # transformer secondary resistance
Ep=230 # rms value of primary voltage
N2byN1=1/3 # turns ratio
Es=Ep*N2byN1 # rms value of secondary voltage
Esm=sqrt(2)*Es # peak value of secondary voltage
Im=Esm/(Rs+Rf+Rl)#
Im=Im*1e3#
print "\n Therefore peak value of current is %.2f mA \n"%(Im)
Idc=Im/pi#
print "\n Average current is %.3f mA \n"%(Idc)
Irms=Im/2 # for half wave rectifier
print "\n rms current is %.3f mA \n"%(Irms)
Idc1=Idc*1e-3#
Edc=Idc1*Rl#
print "\n DC output voltage is %.2f V \n"%(Edc)
Pdc=Edc*Idc1 # Dc output power
Irms1=Irms*1e-3#
Pac=Irms1**2*(Rs+Rf+Rl) # AC output power
n=Pdc/Pac*100 # efficiency
print "\n Efficiency is %.2f %% \n"%(n)
print "Ripple factor for half wave rectifier is 1.21"
```

In [4]:

```
from math import sqrt, pi
from __future__ import division
print "Refer to the figure-3.8 shown"
Vin=0 # cut-in voltage for an ideal diode is zero
Rf=0 # forward resistance for an ideaal diode is zero
print "For an ideal diode"
Vm=15#
Vdc=-Vm/pi#
print "\n DC output voltage is %.2f V\n "%(Vdc)
print "-ve sign indicates that voltage is negative wrt ground"
print "For a silicon diode Vin=0.7V "
Vin=0.7#
Vdc=-(Vm-Vin)/pi#
print "\n DC output voltage is %.2f V\n "%(Vdc)
print "-ve sign indicates that voltage is negative wrt ground"
```

In [5]:

```
from math import sqrt, pi
from __future__ import division
Rl=1 # load resistance in kohm
Vm=10#
print "For an ideal diode Vin= 0V"
Vin=0 # for ideal diode
Rf=0 # for ideal diode
Edc=Vm/pi#
Idc=Edc/Rl#
print "\n Dc voltage is %.2f V and load current is %.2f mA \n"%(Edc,Idc)
print "For a silicon diode Vin=0.7 V"
Vin=0.7#
Edc=(Vm-Vin)/pi#
Idc=Edc/Rl
print "\n Dc voltage is %.2f V and load current is %.2f mA \n"%(Edc,Idc)
```

In [6]:

```
from math import sqrt, pi
from __future__ import division
Esm=300 # peak rms voltage
Edc=Esm/pi # average output voltage
print "\n average output voltage is %.3f V"%(Edc)
```

In [7]:

```
from math import sqrt, pi
from __future__ import division
Es=30 # rms voltage
Rf=2#
Rs=8#
Rl=1e3 # in kohm
Esm=sqrt(2)*Es # peak value of voltage
Im=Esm/(Rf+Rl+Rs) # peak value of current
Idc=2*Im/pi # average current for full wave rectifier
P=Idc**2*Rl#
print " Power delivered to the load is %.3f W \n"%(P)
Vdc_noload=2*Esm/pi#
print "\n Vnl=%f \n"%(Vdc_noload)
Vdc_fullload=Idc*Rl#
print "\n Vfl=%.2f \n"%(Vdc_fullload)
reg=(Vdc_noload-Vdc_fullload)/Vdc_fullload*100#
print "\n percentage regulation is %f %% \n"%(reg)
print "Efficiency of rectification =(DC output)/(AC output)"
x=(1+(Rf+Rs)/Rl)**(-1)#
n=8/pi**2*x*100#
print "\n Efficiency of rectification is %.1f %% \n"%(n)
Irms=Im/sqrt(2)#
AC_rating=Es*Irms#
TUF=P/AC_rating#
print "\n TUF of secondary is %.3f"%(TUF)
#The exact answer for percentage regulation is 1% not .97% as shown in the book ....
#because in the book it has rounded off the value 27.009 to 27 only
```

In [8]:

```
from math import sqrt, pi
from __future__ import division
print "Refer to the figure-3.16 shown"
Rl=100#
Idc=1 # maximum value of DC current in each diode
print "We know Idc=Im/pi for each diode"
Vm=pi*Rl*Idc#
Vp=2*Vm#
print "\n maximum peak to peak voltage is %.2f V"%Vp
```

In [9]:

```
from math import sqrt, pi
from __future__ import division
Rf=1#
Es=10#
Rs=5#
Esm=sqrt(2)*Es#
Edc_nl=2*Esm/pi#
print "Therefore o load DC output voltage is %.4f V \n"%(Edc_nl)
Idc=100e-3#
print "We know that Idc=2Im/pi and Im=Esm/(Rf+rs+rl)"
Im=Idc*pi/2#
Rl=Esm/Im-Rf-Rs # load resistance
Edc_ol=Idc*Rl # DC output voltage at 100mA
print "\n DC output voltage at 100mA is %.4f V \n "%(Edc_ol)
reg=(Edc_nl-Edc_ol)/Edc_ol*100#
print "\n percentage regulation is %.2f %%"%(reg)
```

In [10]:

```
from __future__ import division
Pdc=500 # for half wave rectifier
n=40.6 # maximum efficiency for half wave rectifier
print " We know that efficiency=Pdc/Pac "
print "for Half wave rectifier "
Pac=Pdc/n*100#
print "\n AC input power is %.3f W \n"%(Pac)
print "for Full wave rectifier "
n=81.2 # maximum efficiency for full wave rectifier
Pac=Pdc/n*100#
print "\n AC input power is %.3f W \n"%(Pac)
```

In [11]:

```
from math import sqrt, pi
from __future__ import division
Rf=10#
Rl=100#
Es=30 # transformer rms voltage
Esm=sqrt(2)*Es # peak value of the voltage
Im=Esm/(Rf+Rl)#
Idc=2*Im/pi#
Edc=Idc*Rl#
print "Average voltage is %.2f V \n"%(Edc)
Pdc=Idc**2*Rl#
Irms=Im/sqrt(2) # rms value of the current
Pac=Irms**2*(Rf+Rl)#
n=Pdc/Pac*100#
print "\n Efficiency is %.2f %%"%n
```

In [12]:

```
from math import sqrt, pi
from __future__ import division
Es=100 # rms value of current
Rf=50 # forward resistance
Rl=950#
Rs=0 # resistance of the transformer secondary which is assumed to be 0 ohm
Esm=sqrt(2)*Es # peak value of the input voltage
Im=Esm/(Rs+Rl+Rf)#
Irms=Im/sqrt(2)#
print "rms value of input current is %.4f A \n"%(Irms)
Idc=2*Im/pi#
print "\n load value of current is %.4f A"%(Idc)
```

In [13]:

```
from math import sqrt, pi
from __future__ import division
Rf=0.1#
Idc=10#
Rs=0#
Es=30 # rms value of input voltage
Esm=sqrt(2)*Es # peak value of the input voltage
Im=Idc*pi/2 # DC output current
print "We know that Im=Esm/(2Rf+Rs+Rl) for fullwave rectifier"
Rl=Esm/Im-2*Rf-0#
print "\n Therefore load resistance is %.1f ohm \n"%(Rl)
Pdc=Idc**2*Rl # Dc output power rating
Irms=Im/sqrt(2) # rms value of input current
Pac=Irms**2*(2*Rf+Rs+Rl) # Ac input power
n=Pdc/Pac*100 # efficiency
print "\n Therefore efficiency is %.2f %% \n"%(n)
```

In [14]:

```
from math import sqrt, pi
from __future__ import division
Rl=5e3#
N1toN2=2 # transformer turns ratio
Ep=460 # rms value of primary voltage
Es=Ep/N1toN2#
Esm=sqrt(2)*Es # peak value of the secondary voltage
Im=Esm/Rl # We neglect forward diode resistance
Idc=2*Im/pi#
print "\n Therefore DC load current is %f A \n"%(Idc)
Edc=Idc*Rl#
print "\n DC load voltage is %.3f V \n"%(Edc)
Rf=.482 # ripple factor for full bridge rectifier
Vrip=Rf*Edc # ripple voltage
print "\n Therefore ripple voltage is %.1f V \n"%(Vrip)
print " Peak value of bridge rectifier=PIV rating of each diode"
PIV=Esm#
print "\n Therefore PIV rating of each diode is %.2f V"%(PIV)
```

In [15]:

```
from math import sqrt, pi
from __future__ import division
Ep=230# #rms value of primary voltage
N2toN1=1/15 # turns ratio
Rf=0 # diode is ideal
Rs=0 # transformer is ideal
Rl=50 # load resistance
Es=Ep*N2toN1 # rms vaue of primary voltage
Esm=sqrt(2)*Es # peak value of input voltage
Im=Esm/(Rs+2*Rf+Rl)#
Idc=2*Im/pi#
Edc=Idc*Rl # load voltage
print "\n Therefore load voltage is %.1f V\n"%(Edc)
Rf=.482 # ripple factor for full wave rectifier
Vrip=Rf*Edc # ripple voltage
print "\n ripple voltage is %.4f V"%(Vrip)
#in the book the ripple voltage has been rounded off to
#6.6516V but the actual ans is 6.6539V
```

In [16]:

```
from math import sqrt, pi
from __future__ import division
Rf=0 # diode forward resistance
Es=240 # rms value of supply voltage
Rl=48 # load resistance
Im=sqrt(2)*Es/(Rl+Rf)#
Idc=2*Im/pi#
print " Average load current is %.3f A \n"%(Idc)
Pdc=Idc**2*Rl#
Irms=Im/sqrt(2) # rms value of input current
Pac=Irms**2*Rl#
n=Pdc/Pac*100 # efficiency
print "\n Therefore efficiency is %.2f %% \n"%(n)
```

In [17]:

```
from math import sqrt, pi
from __future__ import division
Esm=100 # peak value of supply voltage
Rf=25 # diode forward voltage
Rl=950 # load resistance
Rt=(2*Rf)+Rl # total resistance
Im=Esm/Rt#
Idc=2*Im/pi#
Edc=Idc*Rl#
print "\n DC output voltage is %f V \n"%(Edc)
Irms=Im/sqrt(2) # rms value of input current
x=(Irms/Idc)**2-1#
Rf=sqrt(x) # ripple factor#
print "\n Therefore ripple factor is %.4f \n"%(Rf)
Pdc=Idc**2*Rl#
Pac=Irms**2*(2*Rf+Rl) # Ac input power
n=Pdc/Pac*100 # efficiency
print "\n Therefore efficiency is %.2f %% \n"%(n)
print "Peak value of bridge rectifier=PIV rating of each diode"
PIV=Esm#
print "\n Therefore PIV rating of each diode is %.2f V"%(PIV)
#In the book the answer for Edc=57.5985V which is wrong because they have taken
#Rf=50 ohm instead of 25 ohm as given in the question similarly
#the efficiency=73.3417% in the book is wrong
#the correct answer for efficiency is 80.97%
```

In [18]:

```
from math import sqrt, pi
from __future__ import division
Rl=100 # load resistance
Es=230 # rms value of input voltage
Rf=0 # ideal diode resistance
Rs=0 # neglecting transformer resistance
f=50 # frequency of the supply
Esm=sqrt(2)*Es # peak value of the input voltage
Edc=2*Esm/pi # as Rf=0 ohm
print "\n Average DC voltage is %.0f V \n"%(Edc)
Im=Esm/Rl#
Idc=2*Im/pi#
print "\n Therefore DC load current is %.2f A \n"%(Idc)
f=2*f # frequency of output waveform
print "\n frequency of output waveform is %.0f Hz"%(f)
```

In [19]:

```
from math import sqrt, pi
from __future__ import division
Edc=12 # output DC voltage
f=50 # frequency
Idc=50e-3#
C=100e-6 # filter capacitor
Rl=2e3 # load resistance
Vr=Edc/(2*f*C*Rl) # rms value of ripple voltage
print "\n rms value of ripple voltage is %.1f V \n "%(Vr)
Rf=(4*sqrt(3)*f*C*Rl)**(-1)*100 # ripple factor
print "\n ripple factor is %.2f %% \n"%(Rf)
```

In [20]:

```
from math import sqrt, pi
from __future__ import division
Es=120 # rms value of input voltage
f=50 # frequency
Idc=50e-3#
C=100e-6 # filter capacitor
Esm=sqrt(2)*Es#
Edc=Esm-Idc/(4*f*C)#
print "\n DC output voltage is %.4f V \n"%(Edc)
Vr=Idc/(4*sqrt(3)*f*C) # rms value of ripple voltage
print "\n rms value of ripple voltage is %.4f V \n "%(Vr)
Rf=Vr/Edc#
print "\n ripple factor is %f \n"%(Rf)
```

In [21]:

```
from math import sqrt, pi
from __future__ import division
Ep=230 # rms value of primary voltage
N1toN2=10 # turns ratio
Rl=50 # load resistance
f=50 # frequency of the supply in Hz
Es=Ep/N1toN2 # rms vaue of secondary voltage or the input voltage
Esm=sqrt(2)*Es # peak value of input voltage
Im=Esm/(Rl)#
Idc=2*Im/pi#
Edc=Idc*Rl # load voltage
print "\n Therefore load voltage is %.1f V \n"%(Edc)
Rf=.48 # ripple factor for full wave rectifier without filter
Vrip=Rf*Edc # ripple voltage
print "\n Ripple factor is 0.48"
print "\n ripple voltage is %.4f V \n"%(Vrip)
print "If the capacitor filter is used then"
C=470e-6 # filter capacitor
Edc=Esm-Idc/(4*f*C)#
print "\n new DC load voltage is %.2f V \n"%(Edc)
Rf=((4*sqrt(3)*f*C*Rl))**(-1) # new ripple factor
Vrip=Rf*Edc # new ripple voltage
print "\n Ripple factor is %.4f"%(Rf)
print "\n rms value of ripple voltage is %.4f V \n "%(Vrip)
# in the book the new ripple factor is 3.256e-3 which is wrong
#the actual answer is 0.1228 hence the new ripple voltage is 3.4544V
# not 0.09156V as shown in the book
```

In [22]:

```
from math import sqrt, pi
from __future__ import division
Rf=.01 # ripple factor in percentage
Rl=2 # load resistance in kohm
f=50 # frequency
print "the %ripple factor=Rf=((4*sqrt(3)*f*C*Rl))**(-1)*100 "
C=((4*sqrt(3)*f*Rf*Rl))**(-1)*100 # filter capacitor
print "\n the filter capacitor is %.3f mF"%(C)
```

In [23]:

```
from math import sqrt, pi
from __future__ import division
Idc=100e-3 # average current
C=500e-6 # filter capacitor
Esm=18 # peak voltage
f=50 # frequency of the supply in Hz
Edc=Esm-Idc/(4*f*C)#
Rl=Edc/Idc # load resistance
Rf=(4*sqrt(3)*f*C*Rl)**(-1)*100 # ripple factor
print "\n ripple factor is %.2f %% \n"%(Rf)
```

In [24]:

```
from math import sqrt, pi
from __future__ import division
f=50 # frequency
C=1000e-6 # filter capacitor
Rl=500 # load resistance
Vrms=120 # rms value of voltage
T1=1e-3 # conduction period of diode,T1=1ms
print "conduction period of diode,T1=1ms"
Esm=sqrt(2)*Vrms # peak value of input voltage
print "Edc=Esm-Idc/(2*f*C) and Idc=Edc/Rl"
Edc=Esm/(1+(2*Rl*f*C)**(-1)) # output dc voltage
Idc=Edc/Rl#
T=1/f#
#Idc*T=Ip*T1
#Ip is the surge current
Ip=Idc*T/T1#
print "\n hence the diode should be rated for a minimum surge\n current of %.2f A \n"%(Ip)
```

In [25]:

```
from math import sqrt, pi
from __future__ import division
Rf=0.1 # riplle facto
Edc=10#
Vrip=Rf*Edc # rms value of voltage
print "\n rms value of ripple voltage is %.0f V \n "%(Vrip)
Vp_p=2*sqrt(2)*Vrip#
print "\n peak to peak voltage is %.4f V "%(Vp_p)
```

In [26]:

```
from math import sqrt, pi
from __future__ import division
Es=230 # rms value of input voltage
f=50 # frequency
Idc=50e-6#
Rl=100 # load resistance
C=1000e-6 # filter capacitor
Esm=sqrt(2)*Es#
Edc=2*Esm/pi#
print "\n Therefore DC output voltage is %.2f V \n"%(Edc)
Idc=Edc/Rl#
print "if the capacitor filter C=1000e-6 is use then "
Rf=(4*sqrt(3)*f*C*Rl)**(-1) # ripple factor
print "\n ripple factor is %.4f \n"%(Rf)
Edc=Esm-Idc/(4*f*C)#
print "\n Therefore new DC load voltage is %.4f V \n"%(Edc)
```

In [27]:

```
from math import sqrt, pi
from __future__ import division
Es=230#
f=50#frequency
Rf=.005 # ripple factor
Il=0.5 # average load current
Esm=sqrt(2)*Es # peak value of input voltage
print " For a half wave rectifier Ripple factor=(2*sqrt(3)*f*C*Rl)**(-1)"
Edc=Esm/pi#for half wave rectifier
Rl=Edc/Il#
C=(2*sqrt(3)*f*Rf*Rl)**(-1) # for half wave rectifier
C=C*1e3#
print "\n Therefore capacitance required is %.3f mF"%(C)
```

In [28]:

```
from math import sqrt, pi
from __future__ import division
Rl=1000#
C=500e-3
f=50#
Rf=(4*sqrt(3)*f*C*Rl)**(-1) # ripple factor
Rf=Rf*1e6#
print "\n ripple factor is %.2f 10**(-6) \n"%(Rf)
```

In [29]:

```
from math import sqrt, pi
from __future__ import division
Il=12e-3 # load current
Es=200 # rms voltage
Rf=0.02 # riplle factor
Esm=sqrt(2)*Es # peak value of input voltage
Edc=2*Esm/pi#
Idc=Il#
Rl=Edc/Idc # load resistance
f=50 # frequency of the supply in Hz
print " For a half wave rectifier Ripple factor=1/(2*sqrt(3)*f*C*Rl)"
C=(4*sqrt(3)*f*Rf*Rl)**(-1) # filter capacitor
print "\n Therefore minimum value of capacitance required is %.3f microF"%(C*1e6)
#C=9.619 microF not 9.622 microF
```

In [30]:

```
from math import sqrt, pi
from __future__ import division
Es=230 # rms voltage
f=50#
Il=10e-3 # load current
Rf=.01 # ripple factor
Esm=sqrt(2)*Es # peak value of input voltage
Edc=2*Esm/pi # for full wave
Rl=Edc/Il#
C=(4*sqrt(3)*f*Rf*Rl)**(-1) # for full wave rectifier
C=C*1e6#
print "\n Therefore capacitance required is %.2f microF"%(C)
```

In [31]:

```
from math import sqrt, pi
from __future__ import division
Rl=2e3 # load resistance
Es=200 # rms voltage
f=50#
Esm=sqrt(2)*Es # peak value of input voltage
Rf=0 # ideal diodes
Rs=0#
Ism=Esm/(Rf+Rs+Rl)#
Idc=2*Ism/pi#
print "\n Therefore Average DC load current is %.2f A \n"%(Idc)
Edc=Idc*Rl#
print "\n Therefore average DC voltage is %.0f V \n"%(Edc)
Rf=0.48 # ripple factor
Vrip=Rf*Edc # ripple voltage
print "\n rms value of ripple voltage is %.1f V \n "%(Vrip)
print "if a filter capacitor C=500 microF is used then"
C=500e-6 # capacitor filter
Rf=(4*sqrt(3)*f*C*Rl)**(-1) # for full wave rectifier
Vrip=Rf*Edc # new ripple voltage
print "\n rms value of new ripple voltage is %.4f V \n "%(Vrip)
```

In [32]:

```
from __future__ import division
Vnl=10 # no load output voltage
Vfl=9.8 # full output voltage
LR=Vnl-Vfl # load regulation
LR=(Vnl-Vfl)/Vfl*100 # percentage load regulation
print "\n percentage load regulation is +%.2f %%"%(LR)
```

In [33]:

```
from __future__ import division
LR=3e-3 # load regulation
Vnl=15 # no load voltage or maximum voltage
Vfl=Vnl-LR # full load voltage
LR=(Vnl-Vfl)/Vfl*100 # percentage load regulation
print "\n percentage load regulation is +%.2f %%"%(LR)
```

In [34]:

```
from __future__ import division
Vhl=10+.3 # high line voltage
Vll=10-.3 # low line voltage
SR=Vhl-Vll # source regulation
Vnom=10 # nominal load voltage
SR=SR/Vnom*100 # percentage source regulation
print "\n percentage source regulation is %.0f %%"%(SR)
```

In [35]:

```
from __future__ import division
print "Refer to the figure-3.45 shown"
Vz=6.1 # zener voltage
Iz_min=2.5e-3 # minimum zener current
Iz_max=25e-3 # maximum zener current
rZ=0 # ideal zener diode
R=2.2e3#
Rl=1e3 # loadd resistance
Il=Vz/Rl#
#For minimum input voltage(Vin_min)
Iz=Iz_min
I=Iz_min+Il#
Vin_min=Vz+I*R#
print "\n minimum input voltage(Vin_min) is %.2f V \n"%(Vin_min)
#For maximum input voltage(Vin_max)
I=Iz_max+Il#
Vin_max=Vz+I*R#
print "\n maximum input voltage(Vin_max) is %.2f V \n"%(Vin_max)
print "\n range of input voltage is from %.3f V to %.2f V \n"%(Vin_min,Vin_max)
```

In [36]:

```
from __future__ import division
Vo=5 # output voltage
Vin_min=12-3 # min input voltage
Vin_max=12+3 # max input voltage
Iz_min=10e-3 # minimum zener current
Il=20e-3 # load current
Pz=500e-3 # Zener wattage
Vz=Vo # zener voltage
print "Step1 : Maximum power dissipation correesponds to Iz_max"
Iz_max=Pz/Vz#
print "\n maximum current that should flow through the zener diode is %.1f A \n"%(Iz_max)
print "Step2 : We know that Il is constant"
#for Vin_max, Iz=Iz_max
I=Il+Iz_max#
Rmin=(Vin_max-Vz)/I#
print "\n minimum resistance required is %.2f ohm \n"%(Rmin)
print "Iz is maximum when R=Rminimum"
print "Step3 : for calculation of Rmax I must be minimum ie I=Iz_min "
I=Il+Iz_min
Rmax=(Vin_min-Vz)/I#
print "\n maximum resistance required is %.2f ohm \n"%(Rmax)
print "\n Thus R must be greater than %.2f ohm and less than \n %.2f ohm for proper regulation \n"%(Rmin,Rmax)
```

In [37]:

```
from __future__ import division
print "refer to the figure-3.47 shown"
Vz=10 # output voltage
Vin=20 # input voltage
Iz_max=25e-3 # maximum zener current
Iz_min=5e-3 # minimum zener current
R=300#
Rz=0 # zener resistance
I=(Vin-Vz)/R#
#for Il_min Iz=Iz_max
Il_min=I-Iz_max # minimum load current
print "\n minimum load current is %.2f mA \n"%(Il_min*1e3)
#for Il_max, Iz=Iz_min
Il_max=I-Iz_min # maximum load current
print "\n maximum load current is %.2f mA \n"%(Il_max*1e3)
Rl_min=Vz/Il_max # minimum load resistance
print "\n minimum load resistance is %.3f ohm \n"%(Rl_min)
# in the book in the question it given that Iz_max=50mA
#but during the solution Iz_max is taken as 25mA I have taken Iz_max=25mA
# in this program
```

In [38]:

```
from __future__ import division
Vo=5#
Il=20e-3#
Pz=500e-3#
Rl=Vo/Il#
Il_min=Il # minimum load current
Il_max=Il # maximum load current
Iz_max=Pz/Vo # maximum zener current
Iz_min=5e-3 # minimum zener current
V=12 # input DC voltage
Vin_min=12-3 # min input voltage
Vin_max=12+3 # max input voltage
Rmax=(Vin_min-Vo)/(Il_max+Iz_min)#
print "\n maximum resistance required is %.0f ohm \n"%(Rmax)
Rmin=(Vin_max-Vo)/(Il_min+Iz_max)#
print "\n minimum resistance required is %.2f ohm \n"%(Rmin)
print "\n So series resistance must be selected between %.2f ohm to %.0f ohm \n"%(Rmin,Rmax)
```

In [39]:

```
from __future__ import division
Vo=10#
Il_min=0 # mainimum load current
Il_max=10e-3 # maximum load current
Iz_max=50e-3 # maximum zener current
Iz_min=2e-3 # minimum zener current
Vin_min=20 # min input voltage
Vin_max=30 # max input voltage
Rl_min=Vo/Il_max#
Rmax=(Vin_min-Vo)/(Il_max+Iz_min)#
print "\n maximum resistance required is %.2f ohm \n"%(Rmax)
Rmin=(Vin_max-Vo)/(Il_min+Iz_max)#
print "\n minimum resistance required is %.0f ohm \n"%(Rmin)
print "\n So series resistance must be selected between %.0f ohm to %.2f ohm \n"%(Rmin,Rmax)
```

In [40]:

```
from __future__ import division
Vo=24#
Il_min=0 # minimum load current
Pz=600e-3#
Vin=32 # input voltage
Iz_max=Pz/Vo#
Rmin=(Vin-Vo)/(Il_min+Iz_max)#
print "\n minimum resistance required is %.0f ohm \n"%(Rmin)
print "\n As Vin and Il are not changing R=Rmin=%.0f ohm\n is sufficient to work as a regulator\n"%(Rmin)
print "For Rl=1200 ohm"
Rl=1200#
Il=Vo/Rl#
print " \n load current is: %.2f A \n"%(Il)
R=Rmin
It=(Vin-Vo)/R#
Iz=It-Il#
print "\n zener current is :%.3f A \n"%(Iz)
print " As Iz=Iz_min=%.3f A, the circuit will work as a regulator"%(Iz)
```

In [41]:

```
from __future__ import division
Pd=400e-3#
Vz=8.1 # output voltage
Vo=Vz#
Zz=8#
Vin=15#
Izm=Pd/Vz#
Rmax=(Vin-Vz)/Izm#
print "\n maximum series resistance is %.3f ohm \n"%(Rmax)
Iz_min=5e-3 # we select the minimum zener current
Il_max=Izm-Iz_min # maximum load current
print "\n maximum load current is %.7f A \n"%(Il_max)
Rl=Vz/Il_max # load resistance
deltaVin=.1*Vin # change in input voltage is equal to 10% of the original input voltage
R=Rmax # series resistance
x=(Rl*Zz)/(Rl+Zz)#
deltaVo=(deltaVin*x)/(R+x)#
Sv=deltaVo/deltaVin # voltage stability factor
print "\n voltage stability factor is %.3f \n"%(Sv)
SR=deltaVo/Vo*100 # line regulation for a 10% change in Vin
print "\n line regulation is %.4f %% \n"%(SR)
deltaIL=Il_max#
y=(R*Zz)/(R+Zz)
deltaVo=deltaIL*y#
LR=deltaVo/Vo*100 # load regulation
print "\n load regulation is %.4f %% \n"%(LR)
z=(Rl*Zz)/(Rl+Zz)
RR=z/(R+z) # ripple rejection ratio
print "\n ripple rejection ratio is %.3f \n"%(RR)
Ro=y # output resistance
print "\n output resistance is %.3f ohm \n"%(Ro)
```