#calculate the spin-spin coupling constants
#Initialization of variables
import math
A=5.1 #Hz
B=-1.4 #Hz
C=3.2 #Hz
an1=120*math.pi/180. #radians
an2=180*math.pi/180. #radians
#calculations
j1=A+B*math.cos(an1) + C*math.cos(2*an1)
j2=A+B*math.cos(an2) + C*math.cos(2*an2)
#results
print '%s %d %s' %("Spin-spin coupling constant =",j1,"Hz")
print '%s %.1f %s' %("\n Spin-spin coupling constant =",j2,"Hz")