abir=float(15.67)
aiki=float(17.23)
auc=float(0.75)
adort=float(93.2)
abes=float
be=float
an=float
kn=float
kontrol=1
x=float
def giris():
print("Yari-Deneysel Kutle Formulunden Yararlanarak Baglanma Enerjisini Bulmak Icin :")
an=input("Atom Numarasini Giriniz : ")
global kn
global x
kn=an
x=an*3
print(an,kn,x)
a=float(abir*kn)
b=float(aiki*(kn**(2.0/3.0)))
c=float(auc*(an**2)/(kn**(1.0/3.0)))
d=float(adort*((kn-(2*an))**2)/kn)
e=float(abes/(kn**(0.5)))
be=a-b-c-d+e
nb=float(be/kn)
print("Atom Numarasi :",kn)
print("Kutle Numarasi :",an)
print("Toplam Baglanma Enerjisi : ",be," MeV'dir.")
print("Nukleon Basi Baglanma Enerjisi : ",nb," MeV'dir.")
print(kn)
kn+=1
def nokontrol():
if kn>0:
if an>0:
if kn%2==0:
if an%2==0:
abes=12
formul()
kontrol=0
else:
abes=0
formul()
kontrol=0
else:
if an%2==0:
abes=0
formul()
kontrol=0
else:
abes=-12
formul()
kontrol=0
elif an<0:
print("Atom Numarasi Sifirdan Kucuk Olamaz.")
else:
print("Atom Numarasi Sifir Olamaz.")
elif kn<0:
print("Kutle Numarasi Sifirdan Kucuk Olamaz.")
elif kn==0 and an==0:
print("Kutle Numarasi ve Atom Numarasi Sifir Olamaz.")
while kontrol==1:
giris()
while an==x:
nokontrol()
这是错误:
Traceback (most recent call last):
a=float(abir*kn)
TypeError: can't multiply sequence by non-int of type 'float'
结果:Yari-Deneysel Kutle 公式 Yararlanarak Baglanma Enerjisini Bulmak Icin ; Atom Numarasini Giriniz : 28 28 28 282828
28 * 3 = 282828 ??? correct : 28 * 3 = 84?
请帮帮我,我刚开始用 Python 学习物理。如果您纠正我的错误,我将不胜感激。代码在 python 3.3 中。参数为原子序数an
、质量数kn
。"an==3*kn"
将继续增加,直到为 1 kn。它扩展到所有“formul()”实现结果的打印。浮点类型错误。d 的孤独。我无法修复这个错误是一个 kin 我能做什么?我的英语不好,对不起