Python,NameError: name ‘math’ is not defined

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

1 #-*- coding : utf-8 -*-
2 import math 3 4 def move(x, y, step, angle=0): 5 nx = x + step * math.cos(angle) 6 ny = y - step * math.sin(angle) 7 return nx, ny

Create a new Python file, save it as move, python interactive interface, import the move function, execute the function, and report an error

Before executing the function, enter

import math

Execute function without error

Similar Posts: