import math
#variable declaration
f1 = 100*1e3 #frequency1 = 100KHz
f2 = 1e9 #frequency2 = 1GHz
T1 = 1.0/f1 #Time period1 = 0.01ms
T2 = 1.0/f2 #Time period2 = 1 ns
#calculation
phi = (0.25)*360.0 # Phase shift(degree)
#result
print "Phase shift = ",round(phi),"Degree","= ",round((round(phi)*math.pi)/180,4), "radian"
import math
#variable Declaration
flow=10*1e3 #Lowest frequency(KHz)
fhigh=100*1e3 #Highest frequency(KHz)
#calculation
bandwidth=fhigh-flow #bandwidth(KHz)
#result
print "Bandwidth=",bandwidth/1000 ,"KHz"
import math
#variable Declaration
B = 10*1e6 # Bandwidth of noisy channel 1MHZ
S_N = 1 # signal to noise ratio is 1
#calculation
C=B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)
#result
print "Capacity of channel =",C/(10*1e6),"Mb/s"
import math
#variable Declaration
fLow = 3*1e6 #low frequency = 3MHz
fHigh = 4*1e6 #high frequency = 4MHz
SNR_dB = 20 #signal to noise ratio 20 dB
#calculation
B = fHigh-fLow #Bandwidth(MHz)
S_N = 10**(SNR_dB/10) #signal to noise ratio
C = B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)
#result
print "Capacity of channel=",round(C/(1e6),1),"Mb/s"
import math
#variable Declaration
P1 = 1 # Let p1 be 1 watt
P2 = P1*0.5 # P2 is half of p1 so 1/2
#calculation
Atten_dB = 10*(math.log(P2/P1)/math.log(10)) #attenuation or loss of power(dB)
#result
print "Attenuation loss =",round(Atten_dB,0), "dB"
import math
#variable Declaration
Loss_line1 = -9 #attenuation of signal between point 1 to 2 = 9 dB
Amp_gain2 = 14 #Amplification of signal between point 2 to 3 = 14 dB
Loss_line3 = -3 #attenuation of signal between point 3 to 4 = 3 dB
#calculation
dB_at_line4 = Loss_line1+Amp_gain2+Loss_line3 #power gain(dB)
#result
print "Power gain for a signal travelling from point1 to another point4 = ",dB_at_line4, "dB"