import math
# Variables
B = 4; #kHz
# Calculations and Results
C = 2*B;
print 'a) C = %ikbits/s'%(C);
C = 2*B*math.log(4,2);
print ' b) for 4-level encoding ,C = %ikbits/s'%(C);
C = 2*B*math.log(128,2);
print ' c) for 128-level encoding ,C = %ikbits/s'%(C);
import math
from numpy import array,log10,log2
# Variables
B = 4; #kHz
SNdb = array([20, 30, 40]); #S/N in db
SN = 10**(SNdb/10); #absolute S/N
# Calculations and Results
C = B*log2(1+SN);
print ' S/Ndb Ckbits/s';
out = [SNdb, C];
print (out);
import math
# Variables
B = 20.; #kHz
C = 160.; #kb/s
# Calculations and Results
M = 2**(C/B/2);
print 'a) Number of encoding levels ,M = %i'%(M);
SN = 2**(C/B)-1;
SNdb = 10*math.log10(SN) #S/N in db
print ' b) S/N = %i S/Ndb) = %.2f dB'%(SN,SNdb);
# Variables
R = 1.; #Mb/s
# Calculations
Bt = R/2; #MHz
# Results
print 'Bt = %i kHz'%(Bt*10**3);