import math
from __future__ import division
#initialisation of variables
eta=0.8; #quantum efficiency of detection
Ps=2e-9; #received optical power in W
h=6.62*1e-34; #plancks constant
lambda1=1500*1e-9; #wavelength in m
c=3*1e8; #velocity of light in m/s
new=c/lambda1; #frequency in Hz
B=1e6; #Signal Bandwidth in Hz
#CALCULATIONS
SNR=(eta*Ps)/(2*h*new*B); #signal to noise ratio
SNRdB=10*math.log10(SNR); #signal to noise ratio in dB)
#RESULTS
print"signal to noise ratio=",round(SNR,5); #the answer in textbook is wrong
print"signal to noise ratio=",round(SNRdB,5),"dB"; #the answer in textbook is wrong