プログラミング

Python3 NameError: name ‘math’ is not defined

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 *

https://yuis.xsrv.jp/images/ss/ShareX_ScreenShot_d34e1d35-9735-43cc-ac5a-0671d17b8102.png

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’ エラーの対応策

関連広告:

Pythonコース by テックアカデミー
Pythonコース by Udemy

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です