from __future__ import division
import math
import cmath
#initializing the variables:
#ratio of output power to input power
rp1 = 2;
rp2 = 25;
rp3 = 1000;
rp4 = 0.01;
#calculation:
#power ratio in decibels
rpd1 = 10*(1/2.303)*math.log(rp1)
rpd2 = 10*(1/2.303)*math.log(rp2)
rpd3 = 10*(1/2.303)*math.log(rp3)
rpd4 = 10*(1/2.303)*math.log(rp4)
#power ratio in nepers
rpn1 = (math.log(rp1))/2
rpn2 = (math.log(rp2))/2
rpn3 = (math.log(rp3))/2
rpn4 = (math.log(rp4))/2
#Results
print "\n\n Result \n\n"
print "\n power ratio in decibels are (a)",round(rpd1,2)," dB (b)",round(rpd2,2)," dB "
print "(c) ",round(rpd3,2)," dB and (d) ",round(rpd4,2)," dB"
print "\n power ratio in nepers are (a)",round(rpn1,2)," Np (b)",round(rpn2,2)," Np"
print "(c) ",round(rpn3,2)," Np and (d) ",round(rpn4,2)," Np"
from __future__ import division
import math
import cmath
#initializing the variables:
rp = 0.05;# power ratio P2/P1
#calculation:
#power ratio in decibels
rpd = 10*(1/2.303)*math.log(rp)
#Results
print "\n\n Result \n\n"
print "\nthe attenuation is ",round(abs(rpd),2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
gain = 1.5;# in dB
Pi = 0.012;# in Watt
#calculation:
#output power
Po = Pi*10**gain
#Results
print "\n\n Result \n\n"
print "\noutput power is ",round(Po,2)," W"
from __future__ import division
import math
import cmath
#initializing the variables:
I2 = 0.05;# in Amperes
rin = 1.32;# in Np
#calculation:
#current input, I1
I1 = I2*math.e**(rin)
#current ratio in decibels
rid = 20*(1/2.303)*math.log(I2/I1)
#Results
print "\n\n Result \n\n"
print "\ncurrent input, I1 is ",round(I1,2)," A"
print "\ncurrent ratio in decibels is ",round(rid,2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
Ra1 = 8; # in ohms
Ra2 = 8; # in ohms
Ra3 = 21; # in ohms
Rb1 = 10; # in ohms
Rb2 = 10; # in ohms
Rb3 = 15; # in ohms
Rc1 = 200; # in ohms
Rc2 = 200; # in ohms
Rc3 = 56.25; # in ohms
#calculation:
R01 = (Ra1**2 + 2*Ra2*Ra3)**0.5
R02 = (Rb1**2 + 2*Rb2*Rb3)**0.5
R03 = (Rc1**2 + 2*Rc2*Rc3)**0.5
#Results
print "\n\n Result \n\n"
print "\n(a) the characteristic impedance, R0 is ",R01," ohm"
print "\n(b) the characteristic impedance, R0 is ",R02," ohm"
print "\n(c) the characteristic impedance, R0 is ",R03," ohm"
from __future__ import division
import math
import cmath
#initializing the variables:
R1 = 500;# in ohm
R2 = 1000;# in ohm
I1 = 1;# in ampere (lets say)
#calculation:
# for symmetrical pi-attenuator section
#characteristic impedance, R0
R0 = (R1*(R2**2)/(R1 + 2*R2))**0.5
#current Ix
Ix = (R2/(R2 + R1 + (R2*R0/(R2 + R0))))*I1
#current I2
I2 = (R2/(R2 + R0))*Ix
ri = I1/I2;# retio of currents
#attenuation
attn = 20*(1/2.303)*math.log(ri)
#Results
print "\n\n Result \n\n"
print "\n the characteristic impedance is ",round(R0,2)," ohm"
print "\n attenuation is ",round(attn,2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
Ra1 = 15;# in ohm
Ra2 = 15;# in ohm
Ra3 = 10;# in ohm
Rb1 = 15;# in ohm
Rb2 = 5;# in ohm
Rb3 = 5;# in ohm
#calculation:
Roc1 = Ra1 + Ra3
Rsc1 = Ra1 + Ra2*Ra3/(Ra2+Ra3)
R01 = (Roc1*Rsc1)**0.5
Roc2 = Rb2* (Rb1 + Rb3)/(Rb1 + Rb2 + Rb3)
Rsc2 = Rb2*Rb1/(Rb2+Rb1)
R02 = (Roc2*Rsc2)**0.5
#Results
print "\n\n Result \n\n"
print "\n (a) the input resistance when the output port is open-circuited is", Roc1," ohm for T-Network"
print "and ",Roc2," ohm for pi-Network "
print "\n (b) the input resistance when the output port is short-circuited is,", Rsc1," ohm for T-Network"
print "and ",Rsc2," ohm for pi-Network "
print "\n (c) the characteristic impedance. is,",round(R01,1)," ohm for T-Network and ,",round(R02,2)," ohm for pi-Network "
from __future__ import division
import math
import cmath
#initializing the variables:
Vat = 20; # in db
R0 = 600;# in ohm
#calculation:
N = math.e**(Vat*2.3/20)
R1 = R0*(N-1)/(N+1)
R2 = R0*2*N/(N**2 - 1)
#Results
print "\n\n Result \n\n"
print "\n For a T-section symmetrical attenuator pad, Resistance R1 is",round(R1,0)," ohm and Resistance R2 is",round(R2,1)," ohm"
from __future__ import division
import math
import cmath
#initializing the variables:
Vat = 20; # in db
R0 = 600;# in ohm
#calculation:
N = math.e**(Vat*2.303/20)
R1 = R0*(N**2 - 1)/(2*N)
R2 = R0*(N+1)/(N-1)
#Results
print "\n\n Result \n\n"
print "\n For a pi-section symmetrical attenuator pad, Resistance R1 is",round(R1/1000,2)," Kohm"
print "and Resistance R2 is",round(R2,0)," ohm"
from __future__ import division
import math
#initializing the variables:
R1 = 300;# in ohm
R2 = 450;# in ohm
I1 = 1;# in ampere (lets say)
#calculation:
#the characteristic impedance of a symmetric T-pad attenuator is given by
R0 = (R1**2 + 2*R1*R2)**0.5
#By current division
#current I2
I2 = (R2/(R2 + R1+ R0))*I1
ri = I1/I2;# ratio of currents
#insertion loss
il = 20*(1/2.303)*math.log(ri)
#Results
print "\n\n Result \n\n"
print "\n the characteristic impedance is ",R0," ohm"
print "\n insertion loss is ",round(il,2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
r = 500;# in ohm
Rhm = 3000;# in ohm
RL = 2000;# in ohm
r1 = 2000;# in ohm
r2 = 1000;# in ohm
E = 1;# in volts (lets say)
#calculation:
#Without the rheostat in the circuit the voltage across the 2 kohm load, VL
VL = (RL/(RL + r))*E
#voltage V2 with 2kohm tapping
V2 = ((RL*r1/(r1 + RL))/((RL*r1/(r1 + RL)) + Rhm - r1 + r))*E
rv1 = VL/V2;# ratio of currents
#insertion loss
il1 = 20*(1/2.303)*math.log(rv1)
#voltage V1 with 1kohm tapping
V1 = ((RL*r2/(r2 + RL))/((RL*r2/(r2 + RL)) + Rhm - r2 + r))*E
rv2 = VL/V1;# ratio of currents
#insertion loss
il2 = 20*(1/2.303)*math.log(rv2)
#Results
print "\n\n Result \n\n"
print "\n insertion loss for 2kohm tap is ",round(il1,2)," dB"
print "\n insertion loss for 1kohm tap is ",round(il2,2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
R1 = 1000;# in ohm
R2 = 500;# in ohm
I1 = 1;# in amperes (lets say)
#calculation:
#characteristic impedance of a symmetrical attenuator
R0 = (R1*(R2**2)/(R1 + 2*R2))**0.5
#current Ix
Ix = (R2/(R2 + R1 + (R2*R0/(R2 + R0))))*I1
#current I2
I2 = (R2/(R2 + R0))*Ix
ri = I1/I2;# retio of currents
#insertion loss
il = 20*(1/2.303)*math.log(ri)
#Results
print "\n\n Result \n\n"
print "\n characteristic impedance is ",round(R0,2)," ohm"
print "\n insertion loss is ",round(il,2)," dB"
from __future__ import division
import math
import cmath
#initializing the variables:
R1 = 100;# in ohm
R2 = 200;# in ohm
R3 = 300;# in ohm
I1 = 1;# in amperes (lets say)
#calculation:
#image impedance Roa
Roa = ((R1 + R2)*(R2 + (R1*R3/(R1 + R3))))**0.5
#image impedance Rob
Rob = ((R1 + R3)*(R3 + (R1*R2/(R1 + R2))))**0.5
#The iterative impedance at port 1
Ri1 = (-1*R1 + (R1**2 - (-1*4*((R2*(R1 + R3)) + (R3*R1))))**0.5)/2
#The iterative impedance at port 2
Ri2 = (R1 + (R1**2 - (-1*4*((R3*(R1 + R2)) + (R2*R1))))**0.5)/2
#Results
print "\n\n Result \n\n"
print "\n image impedance are ",round(Roa,2)," ohm and ",round(Rob,2)," ohm "
print "\n iterative impedances are ",round(Ri1,2)," ohm and ",round(Ri2,2)," ohm "
from __future__ import division
import math
import cmath
#initializing the variables:
R1 = 1000;# in ohm
R2 = 2000;# in ohm
R3 = 3000;# in ohm
I1 = 1;# in amperes (lets say)
#calculation:
#image impedance Roa
Roa = (((R3 + R2)*R1/(R1 + R2 + R3))*(R1*R3/(R1 + R3)))**0.5
#image impedance Rob
Rob = (((R3 + R1)*R2/(R1 + R2 + R3))*(R2*R3/(R2 + R3)))**0.5
#The iterative impedance at port 1
Ri1 = (-1*R1 + ((R1**2) - (-1*4*2*R2*R1))**0.5)/(2*2)
#The iterative impedance at port 2
Ri2 = (R1 + ((-1*R1)**2 - (-1*4*2*R2*R1))**0.5)/(2*2)
#Results
print "\n\n Result \n\n"
print "\n image impedance are ",round(Roa,2)," ohm and ",round(Rob,2)," ohm "
print "\n iterative impedances are ",round(Ri1,2)," ohm and ",round(Ri2,2)," ohm "
from __future__ import division
import math
import cmath
#initializing the variables:
r = 500;# in ohm
RL = 100;# in ohm
E = 1;# in volts (lets say)
#calculation:
#res.
R1 = (r*(r - RL))**0.5
R2 = (r*RL**2/(r - RL))**0.5
#current I1
I1 = E/(r + R1 + R2*RL/(RL + R2))
#current I2
I2 = (R2/(R2 + RL))*I1
#input power
P1 = r*I1**2
#output power
P2 = RL*I2**2
#attenuation
attn = 10*(1/2.303)*math.log(P1/P2)
#Load current, IL
IL = E/(r + RL)
#voltage, VL
VL = IL*RL
#voltage, V1
V1 = E - I1*r
#voltage, V2
V2 = V1 - I1*R1
#insertion loss
il = 20*(1/2.303)*math.log(VL/V2)
#Results
print "\n\n Result \n\n"
print "\n R1 = ",round(R1,2)," ohm and R2 = ",round(R2,2)," ohm "
print "\n attenuation is ",round(attn,2)," dB "
print "\n In decibels, the insertion loss is ",round(il,2)," dB "
from __future__ import division
import math
import cmath
#initializing the variables:
attnO = 70;# in dB
n = 5;# numbers of identical atteneurs
V1 = 0.02;# in Volts
#calculation:
#attenuation of each section
attn = attnO/n
#output of the final stage
Vo = V1/(10**(attnO/20))
#voltage output of the third stage
V3 = V1/(10**(3*attn/20))
#Results
print "\n\n Result \n\n"
print "\n attenuation of each section = ",round(attn,2)," dB "
print "\n output of the final stage is ",round(Vo*1E6,2),"uV "
print "\n voltage output of the third stage is ",round(V3*1E3,3),"mV "
from __future__ import division
import math
import cmath
#initializing the variables:
r = 450; # in ohm
R0 = 450; # in ohms
x = 1/8
#calculation:
N = 1/x
R1 = R0*(N-1)/(N+1)
R2 = R0*2*N/(N**2 - 1)
Io = x*x
attn = 20*math.log10(N)
attnO = 4*attn
#Results
print "\n\n Result \n\n"
print "\n (a)For a T-section symmetrical attenuator pad, Resistance R1 is",round(R1,2)," ohm "
print "and Resistance R2 is",round(R2,0)," ohm"
print "\n (b)current flows in the load = ",round(Io,2),"of the original current."
print "\n (c)overall attenuation is ",round(attnO,2),"dB "