from math import pi,sqrt,atan
# Calculate (a)the cutoff frequency fc# (b)Vout at fc# (c)Theta at fc (Assume Vin = 10 Vpp for all frequencies)
# Given data
R = 10.*10**3# # Resistor=10 kOhms
C = 0.01*10**-6# # Capacitor=0.01 uFarad
Vin = 10.# # Input Voltage=10Vpp
# To calculate fc
fc = 1./(2*pi*R*C)#
print 'The Cutoff Frequency = %0.2f Hertz'%fc
print 'i.e 1.592 kHz'
# To calculate Vout at fc
Xc = 1./(2*pi*fc*C)#
Zt = sqrt((R*R)+(Xc*Xc))#
Vout = Vin*(Xc/Zt)#
print 'The Output Voltage = %0.2f Vpp'%Vout
# To calculate Theta
Theta = atan(-(R/Xc))*180/pi
print 'The Phase angle (Theta z) = %0.2f Degree'%Theta
from math import pi,sqrt,atan
# Calculate (a)the cutoff frequency fc# (b)Vout at 1 kHz# (c)Theta at 1 kHz (Assume Vin = 10 Vpp for all frequencies)
# Given data
R = 1.*10**3# # Resistor=1 kOhms
L = 50.*10**-3 # Inductor=50 mHenry
Vin = 10.# # Input Voltage=10Vpp
f = 1.*10**3# # Frequency=1 kHz
# To calculate fc
fc = R/(2*pi*L)#
print 'The Cutoff Frequency = %0.2f Hertz'%fc,
print 'i.e 3.183 kHz'
# To calculate Vout at fc
Xl = 2*pi*f*L#
Zt = sqrt((R*R)+(Xl*Xl))#
Vout = Vin*(R/Zt)#
print 'The Output Voltage = %0.2f Vpp'%Vout
print 'approx 9.52 Volts(p-p)'
# To calculate Theta
Theta = atan(-(Xl/R))*180/pi
print 'The Phase angle (Theta z) = %0.2f Degree'%Theta
from math import pi,sqrt
# Calculate the cutoff frequency for (a) the RC high-pass filter# (b) the RL high-pass filter
# Given data
R = 1.5*10**3# # Resistor=1.5 kOhms
L = 100.*10**-3 # Inductor=100 mHenry
C = 0.01*10**-6# # Capacitor=0.01 uFarad
# To calculate fc for RC high-pass filter
fc = 1./(2*pi*R*C)#
print 'The Cutoff Frequency for RC High-Pass Filter = %0.2f Hertz'%fc
print 'i.e 10.61 kHz'
# To calculate fc for RL high-pass filter
fc1 = R/(2*pi*L)#
print 'The Cutoff Frequency for RL High-Pass Filter = %0.2f Hertz'%fc1
print 'approx 2.39 kHz'
from math import pi
# Calculate the cutoff frequencies fc1 and fc2.
#Given data
R1 = 1.*10**3# # Resistor 1=1 kOhms
C1 = 1.*10**-6# # Capacitor 1=1 uFarad
R2 = 100.*10**3# # Resistor 2=100 kOhms
C2 = 0.001*10**-6# # Capacitor 2=0.001 uFarad
# To calculate fc1 for RC high-pass filter
fc1 = 1/(2*pi*R1*C1)#
print 'The Cutoff Frequency for RC High-Pass filter = %0.2f Hertz'%fc1
print 'i.e 159 Hz'
# To calculate fc2 for RC high-pass filter
fc2 = 1/(2*pi*R2*C2)#
print 'The Cutoff Frequency for RC High-Pass filter = %0.2f Hertz'%fc2
print 'i.e 1.59 kHz'
from math import pi
# Calculate the notch frequency fn if R1 is 1 kOhms and C1 is 0.01 uF. Also, calculate the required values for 2R1 and 2C1 in the low-pass filter.
# Given data
R1 = 1.*10**3# # Resistor 1=1 kOhms
C1 = 0.01*10**-6# # Capacitor 1=0.01 uFarad
# To calculate Notch frequency fn for RC low-pass filter
fn = 1/(4*pi*R1*C1)#
print 'The Notch Frequency for RC Low-Pass filter = %0.2f Hertz'%fn
print 'i.e 7.96 kHz'
A = 2*R1#
print 'The Required Value of 2R1 = %0.2f Ohms'%A
print 'i.e 2 kohms'
B = 2*C1#
print 'The Required Value of 2C1 = %0.2e Ohms'%B
print '0.02 uF'
from math import log10
# A certain amplifier has an input power of 1 W and an output power of 100 W.Calculate the dB power gain of the amplifier.
# Given data
Pi = 1.# # Input power=1 Watts
Po = 100.# # Output power=100 Watts
N = 10*log10(Po/Pi)#
print 'The Power Gain of Amplifier = %0.2f dB'%N
from math import log10
# The input power to a filter is 100 mW, and the output power is 5 mW. Calculate the attenuation, in decibels, offered by the filter.
# Given data
Pi = 100.*10**-3# # Input power=1 Watts
Po = 5.*10**-3# # Output power=100 Watts
N = 10*log10(Po/Pi)#
print 'The Attenuation offered by the Filter = %0.2f dB'%N
from math import pi,log10,sqrt
# Calculate the attenuation, in decibels, at the following frequencies: (a) 0 Hz# (b) 1.592 kHz# (c) 15.92 kHz. (Assume that Vin is 10 V p-p at all frequencies.)
# Given data
f1 = 0# # Frequency 1=0 Hz
f2 = 1.592*10**3# # Frequency 2=1.592 kHz (cutoff frequency)
f3 = 15.92*10**3# # Frequency 3=15.92 kHz
Vi = 10.# # Voltage input=10 Volts(p-p)
R = 10.*10**3# # Resistor 1=10 kOhms
C = 0.01*10**-6# # Capacitor 1=0.01 uFarad
Vo1 = Vi#
Vo2 = 0.707*Vi#
# At 0 Hz
N1 = 20*log10(Vo1/Vi)#
print 'The Attenuation at 0 Hz = %0.f dB'%N1
#At 1.592 kHz (cutoff frequency)
N2 = 20*log10(Vo2/Vi)#
print 'The Attenuation at 1.592 kHz = %0.2f dB'%N2
# At 15.92 kHz
Xc = 1./(2*pi*f3*C)#
A = R*R#
B = Xc*Xc#
Zt = sqrt (A+B)#
N3 = 20*log10(Xc/Zt)#
print 'The Attenuation at 15.92 kHz = %0.2f dB'%N3