def move(x, y, step, angle=0):
nx = x + step math.cos(angle)
ny = y - step math.sin(angle)
return nx, ny
以上这部分内容我编辑然后保存为my1st.py
然后打开python3 进入交互模式:
输入:
from my1st import move
x,y = move(100,100,60,math.pi / 6)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'math' is not defined
macandle
在本篇的学习过程中:
import math
def move(x, y, step, angle=0): nx = x + step math.cos(angle) ny = y - step math.sin(angle) return nx, ny
以上这部分内容我编辑然后保存为my1st.py
然后打开python3 进入交互模式:
输入:
为什么会这样?
x, y = move(100, 100, 60, math.pi / 6)中的 math.pi /6 是啥意思?