Pythonプログラミング言語において、”NameError: name ‘math’ is not defined”エラーが起こる場合があります。エラーの対処方法と解決方法について紹介します。
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> math.pi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'math' is not defined
解決
モジュールをインポートしなければいけない
from math import *
Python : name ‘math’ is not defined Error? – Stack Overflow
関連記事:
Windows 11にPythonをインストールする
Pythonのバージョン管理をする方法とpyenvの使い方
Pycharmの有料版を無料でインストールするには
Pythonで投資の複利計算をする
Imagededupで類似画像を抽出、検出する(Python)
自然言語テキストが何語なのか判定する [fastText]
Pythonで AttributeError: ‘module’ object has no attribute ‘SSL_ST_INIT’ エラーの対応策
関連広告: