-2
你好,我是新來的蟒蛇,我試圖讓一個程序,做了二次公式,但由於某種原因,它不會增加兩個變量共同Python的 - 兩個variabels不加在一起
#The Quadratic Formula Calculator
from cmath import sqrt
a = (int(input('Enter the value of A : ')))
b = (int(input('Enter the value of B : ')))
c = (int(input('Enter the value of C : ')))
def state_formula():
print('Calculating')
btimesb = b * b
print('First step is done, the value is', btimesb)
fourac = -4 * a * c
print ('The second step is done, the value is', fourac)
squareit = sqrt(btimesb + fourac)
print('The third step is done, the value is', squareit)
negativeb = -b
print('The fourth step is done, the value is', negativeb)
addthemplus = negativeb + squareit
print('The fith step is done, the value is', addthemplus)
和我它出來作爲
Enter the value of A : 3
Enter the value of B : 3
Enter the value of C : 3
First step is done, the value is 9
The second step is done, the value is -36
The third step is done, the value is 5.196152422706632j
The fourth step is done, the value is -3
The fith step is done, the value is (-3+5.196152422706632j)
我想知道,爲什麼第五步實際上並沒有將兩者結合起來,我試圖將其轉換爲浮動,並沒有讓我。
你是什麼意思,「實際上沒有把兩者加在一起」?看起來加入了我。這不像有一些簡單的方法來編寫-3 + 5.196152422706632j。 – user2357112
好的謝謝,不知道是不是正確 –
附加的'j'表示它是一個複數的虛數部分。一個實數「-3」加一個複數「5.196152422706632j」只是另一個複數(這次是實數部分):'-3 + 5.196152422706632j' – MSeifert