【发布时间】:2017-01-25 03:58:55
【问题描述】:
from math import sin, cos, pi
import numpy as np
N=10
a=np.random.randint(0, 360+1, N)
print (a)
theta=a*pi/180
print(theta)
x=[cos(theta)]
print(x)
y=[sin(theta)]
print(y)
TypeError Traceback (most recent call last)
<ipython-input-47-632b45c2aba1> in <module>()
9 theta=a*pi/180
10 print(theta)
---> 11 x=[cos(theta)]
12 print(x)
13 y=[sin(theta)]
TypeError: only length-1 arrays can be converted to Python scalars
【问题讨论】:
-
请用代码块格式化您的代码
-
问题是什么?
标签: python arrays numpy random polar-coordinates