Python 3编码

  1. Generate a list with angles from 0 to 359 degrees step 2 degrees
  2. Using a for loop calculate other vector with the cosine values of the angle. (I am getting an error in this part - invalid syntax)

    Generate a list with angles from 0 to 359 degreees step 2 degrees

    angles=np.arange(0,360,2)
    print(angles)
    

    Using a for loop calculate other vector with the cosine values of the angles

    for x in cosine=np.cos(radians)
        print(x)
    
评论
  • wnihil
    wnihil 回复

    尝试此操作以获取1个数组中所有角度的余弦值:

    angles = np.arange(0, 360, 2)
    for cosine in np.cos(np.deg2rad(angles)):
        print(cosine)