#Initialisation
n=8 #8 bit
n2=16 #16 bit
n3=32 #32 bit
#Calculation
c=2**n #value for 8 bit
c2=2**n2 #value for 16 bit
c3=2**n3 #value for 32 bit
#Result
print'An 8-bit word can take 2^8 = %d values\n'%c
print'An 16-bit word can take 2^16 = %d values\n'%c2
print'An 32-bit word can take 2^32 = %f x 10^9 values\n'%(c3/10**9)
#Initialisation
n=8 #8 bit
n2=16 #16 bit
n3=32 #32 bit
#Calculation
c=2**n #value for 8 bit
p=(1*c**-1)*100 #percent
c2=2**n2 #value for 16 bit
p2=(1*c2**-1)*100 #percent
c3=2**n3 #value for 32 bit
p3=(1*c3**-1)*100 #percent
#Result
print'An 8-bit word resolution = %.2f percent\n'%p
print'An 16-bit word resolution = %.4f percent\n'%p2
print'An 32-bit word resolution = %.9f percent\n'%p3
import numpy as np
import matplotlib.pyplot as plt
#data
x = np.linspace(0, 3, 1)
y=2
#plotting
plt.bar(1, y, 0.001*max(x))
xlabel("Frequency in kHz")
ylabel("Voltage")
title("Frequency Spectrum")
plt.axis([0, 2, 0, 3])
plt.grid()
plt.show()
import numpy as np
import matplotlib.pyplot as plt
#data
x = np.linspace(0, 3, 1)
y=2
y1=1
#plotting
plt.bar(1, y, 0.001*max(x))
plt.bar(1.5, y1, 0.001*max(x))
xlabel("Frequency in kHz")
ylabel("Voltage")
title("Frequency Spectrum")
plt.axis([0, 2, 0, 3])
plt.grid()
plt.show()
#Initialisation
f1=7000 #Human Speech Frequency Upper limit in HZ
f2=50 #Human Speech Frequency Lower limit in Hz
#Calculation
B=f1-f2 #Bandwidth in Hz
#Result
print'Bandwidth = %.1f kHz'%(B*1000**-1)