我做了一個程序。我分配給自己的作業並沒有完成很多python,更多的是一個C++有點兒的人。我無法找到的bug,我只是得到一個可能很容易的bug,找不到它,python新增
syntax error: invalid syntax line 88
該生產線是"print "Attenuation Constant = ", Ac"
z = input("The depth in meters = ")
S = input("salinity in p.s.u. = ")
T = input("temperature in C = ")
pH = input("pH = ")
f = input("frequency of the propagating wave = ")
#relaxation of Boric acid
c = 1,412 + (3.21*T) + (1.19*S) + (.0167*Z)
A_1 = (8.86/c)(10**(.78*pH - 5))
P_1 = 1
f_1 = 2.8*sqrt(S/35)*10**(4 - (1245/(T+273)))
#contribution of Magnesium sulphate
A_2 = 21.44(S/c)(1+0.25*T)
P_2 = (1 - 1.37 * 10**(-4)*z) + (6.2*10**(-9)*z**(2))
f_2 = (8.17 * 10**(8-1990/(T+273)))/(0.0018 (S-35)+1)
#contribution of the viscosity of pure water is
P_3 = 1 - (3.83 * 10^(-5) * z) + (4.9 * 10^(-10) * z**(2))
if T <= 20:
A_3 = 4.937 * 10**(-4) - 2.590 * 10**(-5) * T + 9.11 * 10**(-7) * T**(2) - 1.5 * 10**(-8) * T**(3)
else:
A_3 = 3.964 * 10**(-4) - 1.146 * 10**(-5) * T + 1.45 * 10**(-7) * T**(2) - 6.5 * 10**(-10) * T**(3)
#all together now
Ac = A_1 * P_1 * ((f_1 * f**(2)) /(f_1**(2) + f**(2)) + A_2 * P_2 * ((f_2 * f**(2)) /(f_2**(2) + f**(2)) + A_3 * P_3 * f**(2)
print "Attenuation Constant = ", Ac
你使用的是Python 2還是3? – 2015-01-21 04:47:38
我認爲','是錯誤的,你需要用'+'來代替它,但我並不是很喜歡phyton。 – bish 2015-01-21 04:51:01
不用'',沒關係。正如@Jordan Trudgett所說,你有一個括號不匹配。 – 2015-01-21 05:08:55