#Given
n=5 #bit
a=10
b=20
c=30
#Calculation
Wlsb=-(1/2.0**n-1)
Wlsb2=(2/2.0**n)
Wlsb3=(4/2.0**n)
V1=a/(2.0**n-1)
V2=b/(2.0**n-1)
V3=c/(2.0**n-1)
Va=(a*2**4+a*2**3+0*2**2+a*2**1+a*2**0)/(2.0**5-1)
Vb=(a*2**4+0*2**3+a*2**2+a*2**1+0*2**0)/(2.0**5-1)
#Result
print"(1) The LSB Weight is ", round(Wlsb,2)
print"(2) The 2nd LSB Weight is ", round(Wlsb2,2),"And 2rd LSB weight is ",Wlsb3
print"(3) Ist LSB causes a change in output voltage is ", round(V1,1)
print" 2nd LSB causes a change in output voltage is ", round(V2,1)
print" 3rdLSB causes a change in output voltage is ", round(V1,1)
print"(4) Output voltage for 11011 is " ,round(Va,2),"Volt"
print" Output voltage for 10110 is " ,round(Vb,2),"Volt"