#python #python_3x
При запуске следующей программы в конце выдается сообщение:
SyntaxError: multiple statements found while compiling a single statement
помогите, пожалуйста, разобраться с проблемой.
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>>
>>> print("Программа вычисления вероятности построения данной таблицы")
a=int(input("Input a: "))
b=int(input("Input b: "))
c=int(input("Input c: "))
d=int(input("Input d: "))
ac==a+c
bd==b+d
ab==a+b
cd==c+d
abcd==a+b+c+d
i=1
suma=0
sumb=0
sumc=0
sumd=0
sumac=0
sumbd=0
sumab=0
sumcd=0
sumabcd=0
sumln=0
exp=0
probability=0
import math
while i <= a:
suma = suma+math.log(i)
i = i+1
while i <= b:
sumb = sumb+math.log(i)
i = i+1
while i <= c:
sumc = sumc+math.log(i)
i = i+1
while i <= d:
sumd = sumd+math.log(i)
i = i+1
while i <= ac:
sumac = sumac+math.log(i)
i = i+1
while i <= bd:
sumbd = sumbd+math.log(i)
i = i+1
while i <= ab:
sumab = sumab+math.log(i)
i = i+1
while i <= cd:
sumcd = sumcd+math.log(i)
i = i+1
while i <= abcd:
sumabcd = sumabcd+math.log(i)
i = i+1
sumln=sumac+sumbd+sumab+sumcd-sumabcd-suma-sumb-sumc-sumd
probability=math.exp(sumln)
print ("probability: "+str(probability))
Ответы
Ответ 1
Ошибка в этих строках: ac==a+c bd==b+d ab==a+b cd==c+d abcd==a+b+c+d нужно писать: ac = a + c bd = b + d ab = a + b cd = c + d abcd = a + b + c + d == — это оператор сравнения. = — оператор присвоения.
Комментариев нет:
Отправить комментарий