请问有人可以帮我用Python吗?当我运行以下代码时,我得到两个L_
AND的输出 1.0 L_1
,但我希望它只是 1。
import math
d_ = 0 # My student number last digit
n_ = 10 + 0 # nth roots of unity
import math as m # for real
import cmath as m # for complex
# K_ [ number of the root]
K_ = 9
Root = m.exp((2 * K_ * m.pi * 1j) / n_) # determine the nth root of unity by using exponential form
Root1 = math.cos((2 * K_ * m.pi / n_)) + 1j * math.sin((2 * K_ * m.pi / n_)) # determine the nth root of unity by using polar form
p_ = (Root) ** (n_) # 10th power of Root
p_1 = (Root1) ** (n_) # 10th power of Root1
L_ = (Root.real ** 2 + Root.imag ** 2) # Test whether the point Root lies on unit circle
L_1 = (Root1.real ** 2 + Root1.imag ** 2) # Test whether the point Root1 lies on unit circle
print L_
print L_1